|
| 1 | +using System; |
| 2 | +using iText.IO.Source; |
| 3 | +using iText.Kernel.Pdf; |
| 4 | +using iText.Layout.Element; |
| 5 | +using iText.Layout.Layout; |
| 6 | +using iText.Layout.Properties; |
| 7 | +using iText.Test; |
| 8 | + |
| 9 | +namespace iText.Layout.Renderer { |
| 10 | + public class AreaBreakRendererUnitTest : ExtendedITextTest { |
| 11 | + [NUnit.Framework.Test] |
| 12 | + public virtual void AddChildTestUnsupported() { |
| 13 | + NUnit.Framework.Assert.That(() => { |
| 14 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 15 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetChildRenderers()); |
| 16 | + areaBreakRenderer.AddChild(new TextRenderer(new Text("Test"))); |
| 17 | + } |
| 18 | + , NUnit.Framework.Throws.InstanceOf<Exception>()) |
| 19 | +; |
| 20 | + } |
| 21 | + |
| 22 | + [NUnit.Framework.Test] |
| 23 | + public virtual void DrawTestUnsupported() { |
| 24 | + NUnit.Framework.Assert.That(() => { |
| 25 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 26 | + areaBreakRenderer.Draw(new DrawContext(new PdfDocument(new PdfWriter(new ByteArrayOutputStream())), null)); |
| 27 | + } |
| 28 | + , NUnit.Framework.Throws.InstanceOf<NotSupportedException>()) |
| 29 | +; |
| 30 | + } |
| 31 | + |
| 32 | + [NUnit.Framework.Test] |
| 33 | + public virtual void GetOccupiedAreaTestUnsupported() { |
| 34 | + NUnit.Framework.Assert.That(() => { |
| 35 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 36 | + areaBreakRenderer.GetOccupiedArea(); |
| 37 | + } |
| 38 | + , NUnit.Framework.Throws.InstanceOf<NotSupportedException>()) |
| 39 | +; |
| 40 | + } |
| 41 | + |
| 42 | + [NUnit.Framework.Test] |
| 43 | + public virtual void HasPropertyTest() { |
| 44 | + //Properties are not supported for AbstractRenderer, and it's expected that the result is false for all the properties. |
| 45 | + //The BORDER property is chosen without any specific intention. It could be replaced with any other property. |
| 46 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 47 | + NUnit.Framework.Assert.IsFalse(areaBreakRenderer.HasProperty(Property.BORDER)); |
| 48 | + } |
| 49 | + |
| 50 | + [NUnit.Framework.Test] |
| 51 | + public virtual void HasOwnPropertyTest() { |
| 52 | + //Properties are not supported for AbstractRenderer, and it's expected that the result is false for all the properties. |
| 53 | + //The BORDER property is chosen without any specific intention. It could be replaced with any other property. |
| 54 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 55 | + NUnit.Framework.Assert.IsFalse(areaBreakRenderer.HasProperty(Property.BORDER)); |
| 56 | + } |
| 57 | + |
| 58 | + [NUnit.Framework.Test] |
| 59 | + public virtual void GetPropertyTest() { |
| 60 | + //Properties are not supported for AbstractRenderer, and it's expected that the result is null for all the properties. |
| 61 | + //The BORDER property is chosen without any specific intention. It could be replaced with any other property. |
| 62 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 63 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetProperty<Property>(Property.BORDER)); |
| 64 | + } |
| 65 | + |
| 66 | + [NUnit.Framework.Test] |
| 67 | + public virtual void GetOwnPropertyTest() { |
| 68 | + //Properties are not supported for AbstractRenderer, and it's expected that the result is null for all the properties. |
| 69 | + //The BORDER property is chosen without any specific intention. It could be replaced with any other property. |
| 70 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 71 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetOwnProperty<Property>(Property.BORDER)); |
| 72 | + } |
| 73 | + |
| 74 | + [NUnit.Framework.Test] |
| 75 | + public virtual void GetDefaultPropertyTest() { |
| 76 | + //Properties are not supported for AbstractRenderer, and it's expected that the result is null for all the properties. |
| 77 | + //The BORDER property is chosen without any specific intention. It could be replaced with any other property. |
| 78 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 79 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetDefaultProperty<Property>(Property.BORDER)); |
| 80 | + } |
| 81 | + |
| 82 | + [NUnit.Framework.Test] |
| 83 | + public virtual void GetPropertyWithDefaultValueTestUnsupported() { |
| 84 | + NUnit.Framework.Assert.That(() => { |
| 85 | + //The BORDER_RADIUS property is chosen without any specific intention. It could be replaced with any other property. |
| 86 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 87 | + areaBreakRenderer.GetProperty(Property.BORDER_RADIUS, 3); |
| 88 | + } |
| 89 | + , NUnit.Framework.Throws.InstanceOf<NotSupportedException>()) |
| 90 | +; |
| 91 | + } |
| 92 | + |
| 93 | + [NUnit.Framework.Test] |
| 94 | + public virtual void SetPropertyTestUnsupported() { |
| 95 | + NUnit.Framework.Assert.That(() => { |
| 96 | + //The BORDER_RADIUS property is chosen without any specific intention. It could be replaced with any other property. |
| 97 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 98 | + areaBreakRenderer.SetProperty(Property.BORDER_RADIUS, 5); |
| 99 | + } |
| 100 | + , NUnit.Framework.Throws.InstanceOf<NotSupportedException>()) |
| 101 | +; |
| 102 | + } |
| 103 | + |
| 104 | + [NUnit.Framework.Test] |
| 105 | + public virtual void DeleteOwnProperty() { |
| 106 | + //The BORDER property is chosen without any specific intention. It could be replaced with any other property. |
| 107 | + //Here we just check that no exception has been thrown. |
| 108 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 109 | + areaBreakRenderer.DeleteOwnProperty(Property.BORDER); |
| 110 | + NUnit.Framework.Assert.IsTrue(true); |
| 111 | + } |
| 112 | + |
| 113 | + [NUnit.Framework.Test] |
| 114 | + public virtual void GetModelElementTest() { |
| 115 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 116 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetModelElement()); |
| 117 | + } |
| 118 | + |
| 119 | + [NUnit.Framework.Test] |
| 120 | + public virtual void GetParentTest() { |
| 121 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 122 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetParent()); |
| 123 | + } |
| 124 | + |
| 125 | + [NUnit.Framework.Test] |
| 126 | + public virtual void SetParentTest() { |
| 127 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 128 | + NUnit.Framework.Assert.AreEqual(areaBreakRenderer, areaBreakRenderer.SetParent(new AreaBreakRenderer(new AreaBreak |
| 129 | + ()))); |
| 130 | + } |
| 131 | + |
| 132 | + [NUnit.Framework.Test] |
| 133 | + public virtual void IsFlushedTest() { |
| 134 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 135 | + NUnit.Framework.Assert.IsFalse(areaBreakRenderer.IsFlushed()); |
| 136 | + } |
| 137 | + |
| 138 | + [NUnit.Framework.Test] |
| 139 | + public virtual void MoveTestUnsupported() { |
| 140 | + NUnit.Framework.Assert.That(() => { |
| 141 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 142 | + areaBreakRenderer.Move(2.0f, 2.0f); |
| 143 | + } |
| 144 | + , NUnit.Framework.Throws.InstanceOf<NotSupportedException>()) |
| 145 | +; |
| 146 | + } |
| 147 | + |
| 148 | + [NUnit.Framework.Test] |
| 149 | + public virtual void GetNextRendererTest() { |
| 150 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 151 | + NUnit.Framework.Assert.IsNull(areaBreakRenderer.GetNextRenderer()); |
| 152 | + } |
| 153 | + |
| 154 | + [NUnit.Framework.Test] |
| 155 | + public virtual void LayoutTest() { |
| 156 | + AreaBreakRenderer areaBreakRenderer = new AreaBreakRenderer(new AreaBreak()); |
| 157 | + LayoutResult layoutResult = areaBreakRenderer.Layout(new LayoutContext(null)); |
| 158 | + NUnit.Framework.Assert.AreEqual(LayoutResult.NOTHING, layoutResult.GetStatus()); |
| 159 | + NUnit.Framework.Assert.IsNull(layoutResult.GetOccupiedArea()); |
| 160 | + NUnit.Framework.Assert.IsNull(layoutResult.GetSplitRenderer()); |
| 161 | + NUnit.Framework.Assert.IsNull(layoutResult.GetOverflowRenderer()); |
| 162 | + NUnit.Framework.Assert.AreEqual(areaBreakRenderer, layoutResult.GetCauseOfNothing()); |
| 163 | + NUnit.Framework.Assert.AreEqual(areaBreakRenderer.areaBreak, layoutResult.GetAreaBreak()); |
| 164 | + } |
| 165 | + } |
| 166 | +} |
0 commit comments