Skip to content

Latest commit

 

History

History
78 lines (63 loc) · 2.61 KB

verify-zip.md

File metadata and controls

78 lines (63 loc) · 2.61 KB

VerifyZip

Verifies all files in a zip archive. This approach combines UseUniqueDirectory with a target per file, to snapshot test all files in a zip archive.

[Fact]
public Task WithZip() =>
    VerifyZip(zipPath);

snippet source | anchor

Filtering

[Fact]
public Task WithZipFiltered() =>
    VerifyZip(
        zipPath,
        include: filePath => filePath.FullName.Contains("Doc"));

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 VerifyZipWithInfo() =>
    VerifyZip(
        zipPath,
        info: "the info");

snippet source | anchor

FileScrubber

VerifyDirectory has an optional parameter fileScrubber that allows file specific scrubbing:

[Fact]
public Task VerifyZipWithFileScrubber() =>
    VerifyZip(
        zipPath,
        fileScrubber: (path, builder) =>
        {
            if (Path.GetFileName(path) == "TextDoc.txt")
            {
                builder.Clear();
                builder.Append("New text");
            }
        });

snippet source | anchor

This applies to files where the extensins is a known text file as defined by FileExtensions.IsText.