Skip to content

Commit d3a0af6

Browse files
authored
Add VerifyFiles (#1465)
* Update Verifier_File.cs * . * . * . * Update Directory.Build.props * . * Update Verifier_File.cs * .
1 parent fc6a210 commit d3a0af6

File tree

85 files changed

+562
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+562
-32
lines changed

docs/mdsource/verify-file.source.md

Lines changed: 18 additions & 1 deletion

docs/verify-file.md

Lines changed: 52 additions & 0 deletions

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<NoWarn>CA1822;CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget;xUnit1051;NU1608;NU1109</NoWarn>
5-
<Version>30.2.0</Version>
5+
<Version>30.3.0</Version>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<LangVersion>preview</LangVersion>
88
<AssemblyVersion>1.0.0</AssemblyVersion>

src/Verify.Expecto.Tests/File1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1

src/Verify.Expecto.Tests/File2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2

src/Verify.Expecto.Tests/Verify.Expecto.Tests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@
1111
<PackageReference Include="ProjectDefaults" PrivateAssets="all" />
1212
<ProjectReference Include="..\Verify.Expecto\Verify.Expecto.csproj" />
1313
</ItemGroup>
14+
<ItemGroup>
15+
<None Update="File2.txt">
16+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
17+
</None>
18+
<None Update="File1.txt">
19+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20+
</None>
21+
</ItemGroup>
1422
<Import Project="$(ProjectDir)..\Verify\buildTransitive\Verify.props" />
1523
<Import Project="$(ProjectDir)..\Verify\buildTransitive\Verify.targets" />
1624
<Import Project="$(ProjectDir)..\Verify.Expecto\buildTransitive\Verify.Expecto.props" />

src/Verify.Expecto/Verifier_File.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ public static SettingsTask VerifyFile(
2020
return Verify(settings, assembly, sourceFile, name, _ => _.VerifyFile(path, info, extension));
2121
}
2222

23+
/// <summary>
24+
/// Verifies the contents of files.
25+
/// </summary>
26+
[Pure]
27+
public static SettingsTask VerifyFiles(
28+
string name,
29+
IEnumerable<string> paths,
30+
VerifySettings? settings = null,
31+
object? info = null,
32+
FileScrubber? fileScrubber = null,
33+
[CallerFilePath] string sourceFile = "")
34+
{
35+
var assembly = Assembly.GetCallingAssembly()!;
36+
return Verify(settings, assembly, sourceFile, name, _ => _.VerifyFiles(paths, info, fileScrubber));
37+
}
38+
2339
/// <summary>
2440
/// Verifies the contents of <paramref name="path" />.
2541
/// Differs from passing <see cref="FileInfo" /> to <code>Verify(object? target)</code> which will verify the full path.

src/Verify.Fixie.Tests/File1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1

src/Verify.Fixie.Tests/File2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2

src/Verify.Fixie.Tests/Verify.Fixie.Tests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
<ProjectReference Include="..\Verify.Fixie\Verify.Fixie.csproj" />
1414
<ProjectReference Include="..\Verify\Verify.csproj" />
1515
</ItemGroup>
16+
<ItemGroup>
17+
<None Update="File1.txt">
18+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
19+
</None>
20+
<None Update="File2.txt">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
</ItemGroup>
1624
<Import Project="$(ProjectDir)..\Verify\buildTransitive\Verify.props" />
1725
<Import Project="$(ProjectDir)..\Verify\buildTransitive\Verify.targets" />
1826
<Import Project="$(ProjectDir)..\Verify.Fixie\buildTransitive\Verify.Fixie.props" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
Key: Value
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
public class VerifyFilesTests
2+
{
3+
public Task Run() =>
4+
VerifyFiles(["File1.txt", "File2.txt"]);
5+
6+
public Task WithInfo() =>
7+
VerifyFiles(
8+
["File1.txt", "File2.txt"],
9+
info: new
10+
{
11+
Key = "Value"
12+
});
13+
14+
public Task WithFileScrubber() =>
15+
VerifyFiles(
16+
["File1.txt", "File2.txt"],
17+
fileScrubber: (_, builder) =>
18+
{
19+
builder.Clear();
20+
builder.Append("New");
21+
});
22+
}

src/Verify.Fixie/Verifier_File.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ public static SettingsTask VerifyFile(
1414
[CallerFilePath] string sourceFile = "") =>
1515
Verify(settings, sourceFile, _ => _.VerifyFile(path, info, extension));
1616

17+
/// <summary>
18+
/// Verifies the contents of files.
19+
/// </summary>
20+
[Pure]
21+
public static SettingsTask VerifyFiles(
22+
IEnumerable<string> paths,
23+
VerifySettings? settings = null,
24+
object? info = null,
25+
FileScrubber? fileScrubber = null,
26+
[CallerFilePath] string sourceFile = "") =>
27+
Verify(settings, sourceFile, _ => _.VerifyFiles(paths, info, fileScrubber));
28+
1729
/// <summary>
1830
/// Verifies the contents of <paramref name="path" />.
1931
/// Differs from passing <see cref="FileInfo" /> to <code>Verify(object? target)</code> which will verify the full path.

src/Verify.MSTest.Tests/File1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1

src/Verify.MSTest.Tests/File2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2

src/Verify.MSTest.Tests/Verify.MSTest.Tests.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
<ProjectReference Include="..\Verify.MSTest\Verify.MSTest.csproj" />
1818
<ProjectReference Include="..\Verify\Verify.csproj" />
1919
<ProjectReference Include="..\Verify.MSTest.SourceGenerator\Verify.MSTest.SourceGenerator.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
20+
<None Update="File2.txt">
21+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
22+
</None>
23+
<None Update="File1.txt">
24+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
25+
</None>
2026
</ItemGroup>
2127

2228
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
Key: Value
3+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[TestClass]
2+
public partial class VerifyFilesTests
3+
{
4+
[TestMethod]
5+
public Task Run() =>
6+
VerifyFiles(["File1.txt", "File2.txt"]);
7+
8+
[TestMethod]
9+
public Task WithInfo() =>
10+
VerifyFiles(
11+
["File1.txt", "File2.txt"],
12+
info: new
13+
{
14+
Key = "Value"
15+
});
16+
17+
[TestMethod]
18+
public Task WithFileScrubber() =>
19+
VerifyFiles(
20+
["File1.txt", "File2.txt"],
21+
fileScrubber: (_, builder) =>
22+
{
23+
builder.Clear();
24+
builder.Append("New");
25+
});
26+
}

src/Verify.MSTest/Verifier_File.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ public static SettingsTask VerifyFile(
1414
[CallerFilePath] string sourceFile = "") =>
1515
Verify(settings, sourceFile, _ => _.VerifyFile(path, info, extension));
1616

17+
/// <summary>
18+
/// Verifies the contents of files.
19+
/// </summary>
20+
[Pure]
21+
public static SettingsTask VerifyFiles(
22+
IEnumerable<string> paths,
23+
VerifySettings? settings = null,
24+
object? info = null,
25+
FileScrubber? fileScrubber = null,
26+
[CallerFilePath] string sourceFile = "") =>
27+
Verify(settings, sourceFile, _ => _.VerifyFiles(paths, info, fileScrubber));
28+
1729
/// <summary>
1830
/// Verifies the contents of <paramref name="path" />.
1931
/// Differs from passing <see cref="FileInfo" /> to <code>Verify(object? target)</code> which will verify the full path.

src/Verify.MSTest/VerifyBase_File.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ public SettingsTask VerifyFile(
1515
[CallerFilePath] string sourceFile = "") =>
1616
Verifier.VerifyFile(path, settings, info, null, sourceFile);
1717

18+
/// <summary>
19+
/// Verifies the contents of files.
20+
/// </summary>
21+
[Pure]
22+
public SettingsTask VerifyFiles(
23+
IEnumerable<string> paths,
24+
VerifySettings? settings = null,
25+
object? info = null,
26+
FileScrubber? fileScrubber = null,
27+
[CallerFilePath] string sourceFile = "") =>
28+
Verifier.VerifyFiles(paths, settings, info, fileScrubber, sourceFile);
29+
1830
/// <summary>
1931
/// Verifies the contents of <paramref name="path" />.
2032
/// Differs from passing <see cref="FileInfo" /> to <code>Verify(object? target)</code> which will verify the full path.

src/Verify.NUnit.Tests/File1.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1

src/Verify.NUnit.Tests/File2.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2

src/Verify.NUnit.Tests/Verify.NUnit.Tests.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
<Reference Include="System.IO.Compression" />
2525
</ItemGroup>
2626

27+
<ItemGroup>
28+
<None Update="File1.txt">
29+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
30+
</None>
31+
<None Update="File2.txt">
32+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
33+
</None>
34+
</ItemGroup>
35+
2736
<Import Project="$(ProjectDir)..\Verify\buildTransitive\Verify.props" />
2837
<Import Project="$(ProjectDir)..\Verify\buildTransitive\Verify.targets" />
2938
<Import Project="$(ProjectDir)..\Verify.NUnit\buildTransitive\Verify.NUnit.props" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Content 2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
Key: Value
3+
}

0 commit comments

Comments
 (0)