Verify a PDF byte array with Verify.ImageMagick

324 views Asked by At

With Verify.ImageMagick, it's possible to verify PDF files by them being converted to images which are then diffed. The default is naturally to compare files on disk, but I would like to verify a byte array. As I can't use ImplicitUsings, I have the following NUnit test:

[Test]
public void VerifyPdf()
{
    var byteArray = GeneratePdf();
    Verifier.Verify(byteArray).UseExtension("pdf");
}

I've added Verify.NuNit to the test project, I've installed Verify support in Rider and to initialize ImageMagic, I have this setup fixture:

[SetUpFixture]
public class PdfTestsSetup
{
    [OneTimeSetUp]
    public void OneTimeSetUp()
    {
        VerifyImageMagick.RegisterPdfToPngConverter();
    }
}

Still, when I run the VerifyPdf test in Rider, it becomes successful, there's no output logged to the console, and "Compare Received/Verified" in Rider does nothing. What am I doing wrong?

1

There are 1 answers

0
Asbjørn Ulsberg On BEST ANSWER

As answered on GitHub, the result of Verifier.Verify() needs to be awaited:

[Test]
public async Task VerifyPdf()
{
    var byteArray = GeneratePdf();
    await Verifier.Verify(byteArray).UseExtension("pdf");
}