Verifies all files in a directory. This approach combines UseUniqueDirectory with a target per file, to snapshot test all files in a directory.
[Fact]
public Task WithDirectory() =>
VerifyDirectory(directoryToVerify);
[Fact]
public Task WithDirectoryFiltered() =>
VerifyDirectory(
directoryToVerify,
include: filePath => filePath.Contains("Doc"),
pattern: "*.txt",
options: new()
{
RecurseSubdirectories = false
});
An optional info
parameter can be supplied to add more context to the test. The instance passed will be json serialized.
[Fact]
public Task WithZipAndStructure() =>
VerifyZip(zipPath, includeStructure: true);
VerifyDirectory
has an optional parameter fileScrubber
that allows file specific scrubbing:
[Fact]
public Task VerifyDirectoryWithFileScrubber() =>
VerifyDirectory(
directoryToVerify,
fileScrubber: (path, builder) =>
{
if (Path.GetFileName(path) == "TextDoc.txt")
{
builder.Clear();
builder.Append("New text");
}
});
This applies to files where the extensions is a known text file as defined by FileExtensions.IsText.