Skip to content

Extends Verify to allow verification of documents via DocNet.

License

Notifications You must be signed in to change notification settings

VerifyTests/Verify.DocNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verify.DocNet

Discussions Build status NuGet Status

Extends Verify to allow verification of documents via DocNet.

See Milestones for release notes. Converts pdf documents to png for verification.

This library uses SixLabors ImageSharp for png generation. For commercial application support visit SixLabors/Pricing.

NuGet package

https://nuget.org/packages/Verify.DocNet/

Usage

Enable Verify.DocNet

[ModuleInitializer]
public static void Initialize()
{
    VerifyDocNet.Initialize();
    VerifyImageMagick.RegisterComparers(
        threshold: 0.13,
        ImageMagick.ErrorMetric.PerceptualHash);
}

snippet source | anchor

VerifyImageMagick.RegisterComparers (provided by https://github.com/VerifyTests/Verify.ImageMagick) allows minor image changes to be ignored.

Verify a file

[Test]
public Task VerifyPdf() =>
    VerifyFile("sample.pdf");

snippet source | anchor

Verify a Stream

[Test]
public Task VerifyPdfStream()
{
    var stream = File.OpenRead("sample.pdf");
    return Verify(stream, "pdf");
}

snippet source | anchor

Result

Samples.VerifyPdf#01.verified.png:

PreserveTransparency

[Test]
public Task VerifyPreserveTransparency() =>
    VerifyFile("sample.pdf")
        .PreserveTransparency();

snippet source | anchor

PageDimensions

[Test]
public Task VerifyPageDimensions() =>
    VerifyFile("sample.pdf")
        .PageDimensions(new(1080, 1920));

snippet source | anchor

VerifySinglePage

[Test]
public Task VerifyFirstPage()
{
    var stream = File.OpenRead("sample.pdf");
    return Verify(stream, "pdf").SinglePage(0);
}

[Test]
public Task VerifySecondPage()
{
    var stream = File.OpenRead("sample.pdf");
    return Verify(stream, "pdf").SinglePage(1);
}

snippet source | anchor

File Samples

http://file-examples.com/

Icon

Pdf designed by Alfredo from The Noun Project.

About

Extends Verify to allow verification of documents via DocNet.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Languages