Bladeren bron

Added missing assertions to test that are supposed to throw an exception

Marcin Ziąbek 4 jaren geleden
bovenliggende
commit
5f636beb9d
2 gewijzigde bestanden met toevoegingen van 63 en 46 verwijderingen
  1. 53 40
      QuestPDF.Examples/DebuggingTesting.cs
  2. 10 6
      QuestPDF.Examples/ImageExamples.cs

+ 53 - 40
QuestPDF.Examples/DebuggingTesting.cs

@@ -1,4 +1,5 @@
 using NUnit.Framework;
+using QuestPDF.Drawing.Exceptions;
 using QuestPDF.Examples.Engine;
 using QuestPDF.Fluent;
 using QuestPDF.Helpers;
@@ -10,54 +11,66 @@ namespace QuestPDF.Examples
         [Test]
         public void Stack()
         {
-            RenderingTest
-                .Create()
-                .PageSize(500, 360)
-                .Render(container =>
-                {
-                    container
-                        .Padding(10)
-                        .Width(100)
-                        .Background(Colors.Grey.Lighten3)
-                        .DebugPointer("Example debug pointer")
-                        .Stack(x =>
-                        {
-                            x.Item().Text("Test");
-                            x.Item().Width(150);
-                        });
-                });
+            Assert.Throws<DocumentLayoutException>(() =>
+            {
+                RenderingTest
+                    .Create()
+                    .PageSize(500, 360)
+                    .Render(container =>
+                    {
+                        container
+                            .Padding(10)
+                            .Width(100)
+                            .Background(Colors.Grey.Lighten3)
+                            .DebugPointer("Example debug pointer")
+                            .Stack(x =>
+                            {
+                                x.Item().Text("Test");
+                                x.Item().Width(150);
+                            });
+                    });
+            });
         }
-        
+
         [Test]
         public void Simple()
         {
-            RenderingTest
-                .Create()
-                .PageSize(500, 360)
-                .Render(container =>
-                {
-                    container
-                        .Padding(10)
-                        .Width(100)
-                        .Background(Colors.Grey.Lighten3)
-                        .Width(150)
-                        .Text("Test");
-                });
+            Assert.Throws<DocumentLayoutException>(() =>
+            {
+                RenderingTest
+                    .Create()
+                    .PageSize(500, 360)
+                    .Render(container =>
+                    {
+                        container
+                            .Padding(10)
+                            .Width(100)
+                            .Background(Colors.Grey.Lighten3)
+                            .Width(150)
+                            .Text("Test");
+                    });
+            });
         }
-        
+
         [Test]
         public void DebugPointer()
         {
-            RenderingTest
-                .Create()
-                .PageSize(500, 360)
-                .Render(container =>
-                {
-                    container
-                        .Width(100)
-                        .DebugPointer("Example debug pointer")
-                        .Width(150);
-                });
+            Assert.Throws<DocumentLayoutException>(() =>
+            {
+                RenderingTest
+                    .Create()
+                    .PageSize(500, 360)
+                    .Render(container =>
+                    {
+                        container
+                            .Background(Colors.Grey.Lighten3)
+                            .Padding(10)
+                            .Width(100)
+                            .DebugPointer("Example debug pointer")
+                            .Width(150)
+                            .Text("Example");
+                    });
+            });
         }
     }
 }

+ 10 - 6
QuestPDF.Examples/ImageExamples.cs

@@ -1,5 +1,6 @@
 using System.IO;
 using NUnit.Framework;
+using QuestPDF.Drawing.Exceptions;
 using QuestPDF.Examples.Engine;
 using QuestPDF.Fluent;
 using QuestPDF.Helpers;
@@ -36,12 +37,15 @@ namespace QuestPDF.Examples
         [Test]
         public void Exception()
         {
-            RenderingTest
-                .Create()
-                .PageSize(PageSizes.A5)
-                .ProducePdf()
-                .ShowResults()
-                .Render(page => page.Image("non_existent.png"));
+            Assert.Throws<DocumentComposeException>(() =>
+            {
+                RenderingTest
+                    .Create()
+                    .PageSize(PageSizes.A2)
+                    .ProducePdf()
+                    .ShowResults()
+                    .Render(page => page.Image("non_existent.png"));
+            });
         }
     }
 }