Extends Verify to allow verification of documents via DocNet.
Converts pdf documents to png for verification.
This library uses SixLabors ImageSharp for png generation. For commercial application support visit SixLabors/Pricing.
https://nuget.org/packages/Verify.DocNet/
[ModuleInitializer]
public static void Initialize()
{
VerifyDocNet.Initialize();
VerifyImageMagick.RegisterComparers(
threshold: 0.13,
ImageMagick.ErrorMetric.PerceptualHash);
VerifyImageMagick.RegisterComparers
(provided by https://github.com/VerifyTests/Verify.ImageMagick) allows minor image changes to be ignored.
[Test]
public Task VerifyPdf() =>
VerifyFile("sample.pdf");
[Test]
public Task VerifyPdfStream()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.pdf"));
return Verify(stream, "pdf");
}
Samples.VerifyPdf.01.verified.png:
[Test]
public Task VerifyPreserveTransparency() =>
VerifyFile("sample.pdf")
.PreserveTransparency();
[Test]
public Task VerifyPageDimensions() =>
VerifyFile("sample.pdf")
.PageDimensions(new(1080, 1920));
[Test]
public Task VerifyFirstPage()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.pdf"));
return Verify(stream, "pdf").SinglePage(0);
}
[Test]
public Task VerifySecondPage()
{
var stream = new MemoryStream(File.ReadAllBytes("sample.pdf"));
return Verify(stream, "pdf").SinglePage(1);
}
Pdf designed by Alfredo from The Noun Project.