<!-- GENERATED FILE - DO NOT EDIT This file was generated by [MarkdownSnippets](https://github.com/SimonCropp/MarkdownSnippets). Source File: /docs/mdsource/verify-zip.source.md To change this file edit the source file and then run MarkdownSnippets. --> # VerifyZip Verifies all files in a zip archive. This approach combines [UseUniqueDirectory](/docs/naming.md#useuniquedirectory) with a target per file, to snapshot test all files in a zip archive. <!-- snippet: VerifyZipXunitV3 --> <a id='snippet-VerifyZipXunitV3'></a> ```cs [Fact] public Task WithZip() => VerifyZip(zipPath); ``` <sup><a href='/src/Verify.XunitV3.Tests/Tests.cs#L148-L154' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyZipXunitV3' title='Start of snippet'>anchor</a></sup> <!-- endSnippet --> ## Filtering <!-- snippet: VerifyZipFilterXunitV3 --> <a id='snippet-VerifyZipFilterXunitV3'></a> ```cs [Fact] public Task WithZipFiltered() => VerifyZip( zipPath, include: filePath => filePath.FullName.Contains("Doc")); ``` <sup><a href='/src/Verify.XunitV3.Tests/Tests.cs#L195-L203' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyZipFilterXunitV3' title='Start of snippet'>anchor</a></sup> <!-- endSnippet --> ## Optional Info An optional `info` parameter can be supplied to add more context to the test. The instance passed will be json serialized. <!-- snippet: VerifyZipWithInfoXunitV3 --> <a id='snippet-VerifyZipWithInfoXunitV3'></a> ```cs [Fact] public Task VerifyZipWithInfo() => VerifyZip( zipPath, info: "the info"); ``` <sup><a href='/src/Verify.XunitV3.Tests/Tests.cs#L168-L176' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyZipWithInfoXunitV3' title='Start of snippet'>anchor</a></sup> <!-- endSnippet --> ## FileScrubber `VerifyZip` has an optional parameter `fileScrubber` that allows file specific scrubbing: <!-- snippet: VerifyZipWithFileScrubberXunitV3 --> <a id='snippet-VerifyZipWithFileScrubberXunitV3'></a> ```cs [Fact] public Task VerifyZipWithFileScrubber() => VerifyZip( zipPath, fileScrubber: (path, builder) => { if (Path.GetFileName(path) == "TextDoc.txt") { builder.Clear(); builder.Append("New text"); } }); ``` <sup><a href='/src/Verify.XunitV3.Tests/Tests.cs#L178-L193' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyZipWithFileScrubberXunitV3' title='Start of snippet'>anchor</a></sup> <!-- endSnippet --> This applies to files where the extensions is a known text file as defined by [FileExtensions.IsText](https://github.com/VerifyTests/EmptyFiles#istext). ## Including structure Use `includeStructure: true` to include a file `structure.verified.md` that contains the zip directory structure. <!-- snippet: VerifyZipWithStructureXunitV3 --> <a id='snippet-VerifyZipWithStructureXunitV3'></a> ```cs [Fact] public Task WithZipAndStructure() => VerifyZip(zipPath, includeStructure: true); ``` <sup><a href='/src/Verify.XunitV3.Tests/Tests.cs#L160-L166' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyZipWithStructureXunitV3' title='Start of snippet'>anchor</a></sup> <!-- endSnippet -->