Browse Source

Add ability to generate ActualOutput in the VisualTest engine

Marcin Ziąbek 2 months ago
parent
commit
7a9b35cc7a
1 changed files with 5 additions and 4 deletions
  1. 5 4
      Source/QuestPDF.VisualTests/VisualTestEngine.cs

+ 5 - 4
Source/QuestPDF.VisualTests/VisualTestEngine.cs

@@ -110,11 +110,7 @@ public static class VisualTestEngine
         var actualOutputPath = Path.Combine(ActualOutputDirectoryName, testCategory);
         var actualOutputPath = Path.Combine(ActualOutputDirectoryName, testCategory);
         var expectedOutputPath = Path.Combine(ExpectedOutputDirectoryName, testCategory);
         var expectedOutputPath = Path.Combine(ExpectedOutputDirectoryName, testCategory);
         
         
-        if (!Directory.Exists(expectedOutputPath))
-            Assert.Inconclusive("Cannot find the expected output folder");
-        
         var testName = TestContext.CurrentContext.Test.Name;
         var testName = TestContext.CurrentContext.Test.Name;
-        var expectedOutputFileCount = Directory.EnumerateFiles(expectedOutputPath, $"{testName}*.png").Count();
         
         
         Directory.CreateDirectory(actualOutputPath);
         Directory.CreateDirectory(actualOutputPath);
 
 
@@ -129,6 +125,11 @@ public static class VisualTestEngine
             File.WriteAllBytes(actualImagePath, actualImages[i]);
             File.WriteAllBytes(actualImagePath, actualImages[i]);
         }
         }
         
         
+        if (!Directory.Exists(expectedOutputPath))
+            Assert.Inconclusive("Cannot find the expected output folder");
+        
+        var expectedOutputFileCount = Directory.EnumerateFiles(expectedOutputPath, $"{testName}*.png").Count();
+        
         if (actualImages.Count != expectedOutputFileCount)
         if (actualImages.Count != expectedOutputFileCount)
             Assert.Fail($"Generated {actualImages.Count} images but expected {expectedOutputFileCount}");
             Assert.Fail($"Generated {actualImages.Count} images but expected {expectedOutputFileCount}");