Skip to content

Latest commit

 

History

History
73 lines (57 loc) · 2.22 KB

verify-file.md

File metadata and controls

73 lines (57 loc) · 2.22 KB

VerifyFile

Verifies the contents of a file.

[Fact]
public Task VerifyFilePath() =>
    VerifyFile("sample.txt");

snippet source | anchor

Optional Info

An optional info parameter can be supplied to add more context to the test. The instance passed will be json serialized.

[Fact]
public Task VerifyFileWithInfo() =>
    VerifyFile(
        "sample.txt",
        info: "the info");

snippet source | anchor

Using a custom extension

[Fact]
public Task VerifyFilePathWithExtension() =>
    VerifyFile("sample.txt", extension: "csv");

snippet source | anchor

Verify a file without using a unit test

Use the functionality of VerifyTests outside of a unit test.

public async Task VerifyExternalFile()
{
    using var verifier = new InnerVerifier(targetDirectory, name: "sample");
    await verifier.VerifyFile(filePath);
}

snippet source | anchor

Result:

{targetDirectory}/sample.verified.txt