# 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.
```cs
[Fact]
public Task WithZip() =>
VerifyZip(zipPath);
```
snippet source | anchor
## Filtering
```cs
[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.
```cs
[Fact]
public Task VerifyZipWithInfo() =>
VerifyZip(
zipPath,
info: "the info");
```
snippet source | anchor
## FileScrubber
`VerifyZip` has an optional parameter `fileScrubber` that allows file specific scrubbing:
```cs
[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 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.
```cs
[Fact]
public Task WithZipAndStructure() =>
VerifyZip(zipPath, includeStructure: true);
```
snippet source | anchor
## PersistArchive
`persistArchive` determines whether the original ZipArchive or zip file should be preserved as a verified file. Defaults to false.
```cs
[Fact]
public Task WithZipAndPersistArchive() =>
VerifyZip(zipPath, persistArchive: true);
```
snippet source | anchor
## ArchiveExtension
When using `persistArchive` the resulting verified archive file extension can be controlled using using the `archiveExtension` parameter.
```cs
[Fact]
public Task WithZipWithCustomExtension() =>
VerifyZip(
File.ReadAllBytes(simpleZipPath),
persistArchive: true,
archiveExtension: "nupkg");
```
snippet source | anchor
The default extension is `zip`.
Using the `VerifyZip` with the `Stream` overload, when the streams is a `FileStream` the extension of underlying file will be respected.
Using the `VerifyZip` with the `string path` overload the extension of underlying file will be respected.