diff --git a/docs/verify-zip.md b/docs/verify-zip.md index 4b8b82495b..d2d1554ff0 100644 --- a/docs/verify-zip.md +++ b/docs/verify-zip.md @@ -31,7 +31,7 @@ public Task WithZipFiltered() => zipPath, include: filePath => filePath.FullName.Contains("Doc")); ``` -snippet source | anchor +snippet source | anchor @@ -48,7 +48,7 @@ public Task VerifyZipWithInfo() => zipPath, info: "the info"); ``` -snippet source | anchor +snippet source | anchor @@ -72,7 +72,7 @@ public Task VerifyZipWithFileScrubber() => } }); ``` -snippet source | anchor +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). @@ -89,5 +89,5 @@ Use `includeStructure: true` to include a file `structure.verified.md` that cont public Task WithZipAndStructure() => VerifyZip(zipPath, includeStructure: true); ``` -snippet source | anchor +snippet source | anchor diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 016bafc095..124926aa77 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ CA1822;CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget - 28.12.1 + 28.13.0 enable preview 1.0.0 diff --git a/src/Verify.Expecto/Verifier_Archive.cs b/src/Verify.Expecto/Verifier_Archive.cs index 9b2eec540a..472384ca29 100644 --- a/src/Verify.Expecto/Verifier_Archive.cs +++ b/src/Verify.Expecto/Verifier_Archive.cs @@ -57,4 +57,22 @@ public static SettingsTask VerifyZip( var assembly = Assembly.GetCallingAssembly()!; return Verify(settings, assembly, sourceFile, name, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); } + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + string name, + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") + { + var assembly = Assembly.GetCallingAssembly()!; + return Verify(settings, assembly, sourceFile, name, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); + } } \ No newline at end of file diff --git a/src/Verify.Fixie.Tests/Tests.cs b/src/Verify.Fixie.Tests/Tests.cs index ce8e72deb9..2a030579b7 100644 --- a/src/Verify.Fixie.Tests/Tests.cs +++ b/src/Verify.Fixie.Tests/Tests.cs @@ -67,6 +67,9 @@ public Task WithZip() => #endregion + public Task WithZipBytes() => + VerifyZip(File.ReadAllBytes(pathToArchive)); + #region VerifyZipWithStructureFixie public Task WithZipAndStructure() => diff --git a/src/Verify.Fixie/Verifier_Archive.cs b/src/Verify.Fixie/Verifier_Archive.cs index cf0df990e5..d379d45a5e 100644 --- a/src/Verify.Fixie/Verifier_Archive.cs +++ b/src/Verify.Fixie/Verifier_Archive.cs @@ -43,4 +43,18 @@ public static SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verify(settings, sourceFile, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verify(settings, sourceFile, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); } \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot b/src/Verify.MSTest.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..2c47b8ae97 --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Sample content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/TextDoc.verified.txt b/src/Verify.MSTest.Tests/Tests.WithZipBytes/TextDoc.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/TextDoc.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt new file mode 100644 index 0000000000..0bf90d8035 --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt @@ -0,0 +1 @@ +Another text content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests b/src/Verify.MSTest.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests new file mode 100644 index 0000000000..6b584e8ece --- /dev/null +++ b/src/Verify.MSTest.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests @@ -0,0 +1 @@ +content \ No newline at end of file diff --git a/src/Verify.MSTest.Tests/Tests.cs b/src/Verify.MSTest.Tests/Tests.cs index 958a0a0f75..f925add3d1 100644 --- a/src/Verify.MSTest.Tests/Tests.cs +++ b/src/Verify.MSTest.Tests/Tests.cs @@ -171,6 +171,11 @@ public Task WithZip() => #endregion + [TestMethod] + public Task WithZipBytes() => + VerifyZip(File.ReadAllBytes(zipPath)); + + [TestMethod] public Task VerifyFileWithRelativePath() => VerifyFile("sample.png"); diff --git a/src/Verify.MSTest/Verifier_Archive.cs b/src/Verify.MSTest/Verifier_Archive.cs index 301a83f098..7533a3dd83 100644 --- a/src/Verify.MSTest/Verifier_Archive.cs +++ b/src/Verify.MSTest/Verifier_Archive.cs @@ -43,4 +43,18 @@ public static SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verify(settings, sourceFile, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verify(settings, sourceFile, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); } \ No newline at end of file diff --git a/src/Verify.MSTest/VerifyBase_Archive.cs b/src/Verify.MSTest/VerifyBase_Archive.cs index b69c12fa8a..d0dd1f5fec 100644 --- a/src/Verify.MSTest/VerifyBase_Archive.cs +++ b/src/Verify.MSTest/VerifyBase_Archive.cs @@ -45,4 +45,18 @@ public SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verifier.VerifyZip(stream, include, settings, info, fileScrubber, includeStructure, sourceFile); + + /// + /// Verifies the contents of a + /// + [Pure] + public SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verifier.VerifyZip(bytes, include, settings, info, fileScrubber, includeStructure, sourceFile); } \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot b/src/Verify.NUnit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..2c47b8ae97 --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Sample content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/TextDoc.verified.txt b/src/Verify.NUnit.Tests/Tests.WithZipBytes/TextDoc.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/TextDoc.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt new file mode 100644 index 0000000000..0bf90d8035 --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt @@ -0,0 +1 @@ +Another text content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests b/src/Verify.NUnit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests new file mode 100644 index 0000000000..6b584e8ece --- /dev/null +++ b/src/Verify.NUnit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests @@ -0,0 +1 @@ +content \ No newline at end of file diff --git a/src/Verify.NUnit.Tests/Tests.cs b/src/Verify.NUnit.Tests/Tests.cs index 23c89561cd..0ef00e50d2 100644 --- a/src/Verify.NUnit.Tests/Tests.cs +++ b/src/Verify.NUnit.Tests/Tests.cs @@ -77,6 +77,10 @@ public Task WithZip() => #endregion + [Test] + public Task WithZipBytes() => + VerifyZip(File.ReadAllBytes(pathToArchive)); + #region VerifyZipWithStructureNunit [Test] diff --git a/src/Verify.NUnit/Verifier_Archive.cs b/src/Verify.NUnit/Verifier_Archive.cs index e5c7c38265..eef4ea4952 100644 --- a/src/Verify.NUnit/Verifier_Archive.cs +++ b/src/Verify.NUnit/Verifier_Archive.cs @@ -43,4 +43,18 @@ public static SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verify(settings, sourceFile, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verify(settings, sourceFile, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); } \ No newline at end of file diff --git a/src/Verify.NUnit/VerifyBase_Archive.cs b/src/Verify.NUnit/VerifyBase_Archive.cs index 957c1d7f78..d50c474a7f 100644 --- a/src/Verify.NUnit/VerifyBase_Archive.cs +++ b/src/Verify.NUnit/VerifyBase_Archive.cs @@ -61,4 +61,24 @@ public SettingsTask VerifyZip( fileScrubber, includeStructure, sourceFile); + + /// + /// Verifies the contents of a + /// + [Pure] + public SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false) => + Verifier.VerifyZip( + bytes, + include, + settings ?? this.settings, + info, + fileScrubber, + includeStructure, + sourceFile); } \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot b/src/Verify.TUnit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..2c47b8ae97 --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Sample content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/TextDoc.verified.txt b/src/Verify.TUnit.Tests/Tests.WithZipBytes/TextDoc.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/TextDoc.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt new file mode 100644 index 0000000000..0bf90d8035 --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt @@ -0,0 +1 @@ +Another text content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests b/src/Verify.TUnit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests new file mode 100644 index 0000000000..6b584e8ece --- /dev/null +++ b/src/Verify.TUnit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests @@ -0,0 +1 @@ +content \ No newline at end of file diff --git a/src/Verify.TUnit.Tests/Tests.cs b/src/Verify.TUnit.Tests/Tests.cs index aea6e72593..5b014ac386 100644 --- a/src/Verify.TUnit.Tests/Tests.cs +++ b/src/Verify.TUnit.Tests/Tests.cs @@ -72,6 +72,10 @@ public Task WithZip() => #endregion + [Test] + public Task WithZipBytes() => + VerifyZip(File.ReadAllBytes(pathToArchive)); + #region VerifyZipWithStructureTunit [Test] diff --git a/src/Verify.TUnit/Verifier_Archive.cs b/src/Verify.TUnit/Verifier_Archive.cs index c3aa07080d..86c3318393 100644 --- a/src/Verify.TUnit/Verifier_Archive.cs +++ b/src/Verify.TUnit/Verifier_Archive.cs @@ -45,4 +45,18 @@ public static SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verify(settings, sourceFile, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verify(settings, sourceFile, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); } \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot b/src/Verify.Xunit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..2c47b8ae97 --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Sample content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/TextDoc.verified.txt b/src/Verify.Xunit.Tests/Tests.WithZipBytes/TextDoc.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/TextDoc.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt new file mode 100644 index 0000000000..0bf90d8035 --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt @@ -0,0 +1 @@ +Another text content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests b/src/Verify.Xunit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests new file mode 100644 index 0000000000..6b584e8ece --- /dev/null +++ b/src/Verify.Xunit.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests @@ -0,0 +1 @@ +content \ No newline at end of file diff --git a/src/Verify.Xunit.Tests/Tests.cs b/src/Verify.Xunit.Tests/Tests.cs index a42fe07711..3036d5b6bc 100644 --- a/src/Verify.Xunit.Tests/Tests.cs +++ b/src/Verify.Xunit.Tests/Tests.cs @@ -126,6 +126,10 @@ public Task WithDirectoryFiltered() => public Task WithZip() => VerifyZip(zipPath); + [Fact] + public Task WithZipBytes() => + VerifyZip(File.ReadAllBytes(zipPath)); + [Fact] public Task VerifyZipWithInfo() => VerifyZip( diff --git a/src/Verify.Xunit/Verifier_Archive.cs b/src/Verify.Xunit/Verifier_Archive.cs index 52edefb2b9..08b372eb9e 100644 --- a/src/Verify.Xunit/Verifier_Archive.cs +++ b/src/Verify.Xunit/Verifier_Archive.cs @@ -45,4 +45,18 @@ public static SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verify(settings, sourceFile, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verify(settings, sourceFile, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); } \ No newline at end of file diff --git a/src/Verify.Xunit/VerifyBase_Archive.cs b/src/Verify.Xunit/VerifyBase_Archive.cs index 5ab77ae905..f6691af985 100644 --- a/src/Verify.Xunit/VerifyBase_Archive.cs +++ b/src/Verify.Xunit/VerifyBase_Archive.cs @@ -63,4 +63,24 @@ public SettingsTask VerifyZip( fileScrubber, includeStructure, sourceFile); + + /// + /// Verifies the contents of a + /// + [Pure] + public SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false) => + Verifier.VerifyZip( + bytes, + include, + settings ?? this.settings, + info, + fileScrubber, + includeStructure, + sourceFile); } \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..2c47b8ae97 --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Sample content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/TextDoc.verified.txt b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/TextDoc.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/TextDoc.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/.verified.TextDocStartingWithDot @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt new file mode 100644 index 0000000000..0bf90d8035 --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/TextDoc2.verified.txt @@ -0,0 +1 @@ +Another text content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension new file mode 100644 index 0000000000..f68255144f --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested.with.dot/TextDocWithoutExtension.verified.noextension @@ -0,0 +1 @@ +Some text content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt new file mode 100644 index 0000000000..640c5ea425 --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/nested/TextDoc2.verified.txt @@ -0,0 +1 @@ +Text content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests new file mode 100644 index 0000000000..6b584e8ece --- /dev/null +++ b/src/Verify.XunitV3.Tests/Tests.WithZipBytes/toConvert.verified.VerifyDirectoryTests @@ -0,0 +1 @@ +content \ No newline at end of file diff --git a/src/Verify.XunitV3.Tests/Tests.cs b/src/Verify.XunitV3.Tests/Tests.cs index c76422a79c..6af9cba737 100644 --- a/src/Verify.XunitV3.Tests/Tests.cs +++ b/src/Verify.XunitV3.Tests/Tests.cs @@ -153,6 +153,10 @@ public Task WithZip() => #endregion + [Fact] + public Task WithZipBytes() => + VerifyZip(File.ReadAllBytes(zipPath)); + #region VerifyZipWithStructureXunitV3 [Fact] diff --git a/src/Verify.XunitV3/Verifier_Archive.cs b/src/Verify.XunitV3/Verifier_Archive.cs index 7ef0e94bcc..1dec61b119 100644 --- a/src/Verify.XunitV3/Verifier_Archive.cs +++ b/src/Verify.XunitV3/Verifier_Archive.cs @@ -43,4 +43,18 @@ public static SettingsTask VerifyZip( bool includeStructure = false, [CallerFilePath] string sourceFile = "") => Verify(settings, sourceFile, _ => _.VerifyZip(stream, include, info, fileScrubber, includeStructure), true); + + /// + /// Verifies the contents of a + /// + [Pure] + public static SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false, + [CallerFilePath] string sourceFile = "") => + Verify(settings, sourceFile, _ => _.VerifyZip(bytes, include, info, fileScrubber, includeStructure), true); } \ No newline at end of file diff --git a/src/Verify.XunitV3/VerifyBase_Archive.cs b/src/Verify.XunitV3/VerifyBase_Archive.cs index 4f8c7e3018..03c751d1c4 100644 --- a/src/Verify.XunitV3/VerifyBase_Archive.cs +++ b/src/Verify.XunitV3/VerifyBase_Archive.cs @@ -61,4 +61,24 @@ public SettingsTask VerifyZip( fileScrubber, includeStructure, sourceFile); + + /// + /// Verifies the contents of a + /// + [Pure] + public SettingsTask VerifyZip( + byte[] bytes, + Func? include = null, + VerifySettings? settings = null, + object? info = null, + FileScrubber? fileScrubber = null, + bool includeStructure = false) => + Verifier.VerifyZip( + bytes, + include, + settings ?? this.settings, + info, + fileScrubber, + includeStructure, + sourceFile); } \ No newline at end of file diff --git a/src/Verify/Verifier/InnerVerifier_Archive.cs b/src/Verify/Verifier/InnerVerifier_Archive.cs index 3975ef8111..211b06f30e 100644 --- a/src/Verify/Verifier/InnerVerifier_Archive.cs +++ b/src/Verify/Verifier/InnerVerifier_Archive.cs @@ -24,6 +24,18 @@ public async Task VerifyZip( return await VerifyZip(archive, include, info, scrubber, includeStructure); } + public async Task VerifyZip( + byte[] bytes, + Func? include, + object? info, + FileScrubber? scrubber, + bool includeStructure) + { + using var stream = new MemoryStream(bytes); + using var archive = new ZipArchive(stream, ZipArchiveMode.Read); + return await VerifyZip(archive, include, info, scrubber, includeStructure); + } + public async Task VerifyZip( ZipArchive archive, Func? include,