Browse Source

Add layout tests for the StopPaging element

Marcin Ziąbek 3 months ago
parent
commit
2c08ec1b91
1 changed files with 108 additions and 0 deletions
  1. 108 0
      Source/QuestPDF.LayoutTests/StopPagingTests.cs

+ 108 - 0
Source/QuestPDF.LayoutTests/StopPagingTests.cs

@@ -0,0 +1,108 @@
+namespace QuestPDF.LayoutTests;
+
+public class StopPagingTests
+{
+    [Test]
+    public void ChildReturnsWrap()
+    {
+        LayoutTest
+            .HavingSpaceOfSize(100, 100)
+            .ForContent(content =>
+            {
+                content.Shrink()
+                    .Mock("a")
+                    .StopPaging() // <- 
+                    .Mock("b")
+                    .SolidBlock(200, 200);
+            })
+            .ExpectDrawResult(document =>
+            {
+                document
+                    .Page()
+                    .RequiredAreaSize(0, 0)
+                    .Content(page =>
+                    {
+                        page.Mock("a").Position(0, 0).Size(0, 0);
+                    });
+            });
+    }
+    
+    [Test]
+    public void ChildReturnsPartialRender()
+    {
+        LayoutTest
+            .HavingSpaceOfSize(100, 100)
+            .ForContent(content =>
+            {
+                content.Shrink()
+                    .Mock("a")
+                    .StopPaging() // <-
+                    .Mock("b")
+                    .ContinuousBlock(50, 150);
+            })
+            .ExpectDrawResult(document =>
+            {
+                document
+                    .Page()
+                    .RequiredAreaSize(50, 100)
+                    .Content(page =>
+                    {
+                        page.Mock("a").Position(0, 0).Size(50, 100);
+                        page.Mock("b").Position(0, 0).Size(50, 100);
+                    });
+                
+                // remaining item space is ignored
+            });
+    }
+    
+    [Test]
+    public void ChildReturnsFullRender()
+    {
+        LayoutTest
+            .HavingSpaceOfSize(100, 100)
+            .ForContent(content =>
+            {
+                content.Shrink()
+                    .Mock("a")
+                    .StopPaging() // <-
+                    .Mock("b")
+                    .SolidBlock(50, 50);
+            })
+            .ExpectDrawResult(document =>
+            {
+                document
+                    .Page()
+                    .RequiredAreaSize(50, 50)
+                    .Content(page =>
+                    {
+                        page.Mock("a").Position(0, 0).Size(50, 50);
+                        page.Mock("b").Position(0, 0).Size(50, 50);
+                    });
+            });
+    }
+    
+    [Test]
+    public void ChildReturnsEmpty()
+    {
+        LayoutTest
+            .HavingSpaceOfSize(100, 100)
+            .ForContent(content =>
+            {
+                content.Shrink()
+                    .Mock("a")
+                    .StopPaging() // <-
+                    .Mock("b");
+            })
+            .ExpectDrawResult(document =>
+            {
+                document
+                    .Page()
+                    .RequiredAreaSize(0, 0)
+                    .Content(page =>
+                    {
+                        page.Mock("a").Position(0, 0).Size(0, 0);
+                        page.Mock("b").Position(0, 0).Size(0, 0);
+                    });
+            });
+    }
+}