This commit is contained in:
GitHub Action 2022-03-11 12:01:21 +00:00
Родитель b2d4b9cf29
Коммит c7ac9f1c6f
9 изменённых файлов: 185 добавлений и 293 удалений

Просмотреть файл

@ -30,9 +30,8 @@ Given the following method:
```cs
public static class ClassBeingTested
{
public static Person FindPerson()
{
return new()
public static Person FindPerson() =>
new()
{
Id = new("ebced679-45d3-4653-8791-3d969c4a986c"),
Title = Title.Mr,
@ -50,10 +49,9 @@ public static class ClassBeingTested
Country = "USA"
}
};
}
}
```
<sup><a href='/src/TargetLibrary/ClassBeingTested.cs#L1-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-classbeingtested' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/TargetLibrary/ClassBeingTested.cs#L1-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-classbeingtested' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -34,7 +34,7 @@ static Task<CompareResult> CompareImages(
return Task.FromResult(result);
}
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L39-L56' title='Snippet source file'>snippet source</a> | <a href='#snippet-imagecomparer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L37-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-imagecomparer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
The returned `CompareResult.NotEqual` takes an optional message that will be rendered in the resulting text displayed to the user on test failure.
@ -57,14 +57,12 @@ public Task InstanceComparer()
}
[Fact]
public Task InstanceComparerFluent()
{
return VerifyFile("sample.png")
public Task InstanceComparerFluent() =>
VerifyFile("sample.png")
.UseStreamComparer(CompareImages)
.UseExtension("png");
}
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L6-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-instancecomparer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L6-L23' title='Snippet source file'>snippet source</a> | <a href='#snippet-instancecomparer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -78,7 +76,7 @@ VerifierSettings.RegisterStreamComparer(
compare: CompareImages);
await VerifyFile("TheImage.png");
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L29-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-staticcomparer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L27-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-staticcomparer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -163,7 +163,7 @@ return new(
return Task.CompletedTask;
});
```
<sup><a href='/src/Verify.Tests/Converters/TypeConverterTests.cs#L43-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-conversionresultwithcleanup' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Converters/TypeConverterTests.cs#L41-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-conversionresultwithcleanup' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -16,12 +16,10 @@ Given a method that returns a named tuple:
<!-- snippet: MethodWithNamedTuple -->
<a id='snippet-methodwithnamedtuple'></a>
```cs
static (bool Member1, string Member2, string Member3) MethodWithNamedTuple()
{
return (true, "A", "B");
}
static (bool Member1, string Member2, string Member3) MethodWithNamedTuple() =>
(true, "A", "B");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1095-L1102' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodwithnamedtuple' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1051-L1056' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodwithnamedtuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Can be verified:
@ -31,7 +29,7 @@ Can be verified:
```cs
await VerifyTuple(() => MethodWithNamedTuple());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1088-L1092' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifytuple' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1044-L1048' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifytuple' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Resulting in:

Просмотреть файл

@ -27,7 +27,7 @@ var settings = new VerifySettings();
settings.UseDirectory("CustomDirectory");
await Verify("value", settings);
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L193-L199' title='Snippet source file'>snippet source</a> | <a href='#snippet-usedirectory' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L179-L185' title='Snippet source file'>snippet source</a> | <a href='#snippet-usedirectory' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
<!-- snippet: UseDirectoryFluent -->
@ -36,7 +36,7 @@ await Verify("value", settings);
await Verify("value")
.UseDirectory("CustomDirectory");
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L205-L210' title='Snippet source file'>snippet source</a> | <a href='#snippet-usedirectoryfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L191-L196' title='Snippet source file'>snippet source</a> | <a href='#snippet-usedirectoryfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in `CustomDirectory/TypeName.MethodName.verified.txt`.
@ -55,7 +55,7 @@ var settings = new VerifySettings();
settings.UseTypeName("CustomTypeName");
await Verify("value", settings);
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L216-L222' title='Snippet source file'>snippet source</a> | <a href='#snippet-usetypename' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L202-L208' title='Snippet source file'>snippet source</a> | <a href='#snippet-usetypename' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
<!-- snippet: UseTypeNameFluent -->
@ -64,7 +64,7 @@ await Verify("value", settings);
await Verify("value")
.UseTypeName("CustomTypeName");
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L228-L233' title='Snippet source file'>snippet source</a> | <a href='#snippet-usetypenamefluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L214-L219' title='Snippet source file'>snippet source</a> | <a href='#snippet-usetypenamefluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in `CustomTypeName.MethodName.verified.txt`.
@ -81,7 +81,7 @@ var settings = new VerifySettings();
settings.UseMethodName("CustomMethodName");
await Verify("value", settings);
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L239-L245' title='Snippet source file'>snippet source</a> | <a href='#snippet-usemethodname' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L225-L231' title='Snippet source file'>snippet source</a> | <a href='#snippet-usemethodname' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in `TestClass.CustomMethodName.verified.txt`.
@ -92,7 +92,7 @@ Will result in `TestClass.CustomMethodName.verified.txt`.
await Verify("value")
.UseMethodName("CustomMethodNameFluent");
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L251-L256' title='Snippet source file'>snippet source</a> | <a href='#snippet-usemethodnamefluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L237-L242' title='Snippet source file'>snippet source</a> | <a href='#snippet-usemethodnamefluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in `TestClass.CustomMethodNameFluent.verified.txt`.
@ -107,16 +107,14 @@ Will result in `TestClass.CustomMethodNameFluent.verified.txt`.
<a id='snippet-multiplecalls'></a>
```cs
[Fact]
public async Task MultipleCalls()
{
await Task.WhenAll(
public Task MultipleCalls() =>
Task.WhenAll(
Verify("Value1")
.UseMethodName("MultipleCalls_1"),
Verify("Value1")
.UseMethodName("MultipleCalls_2"));
}
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L54-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-multiplecalls' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L54-L64' title='Snippet source file'>snippet source</a> | <a href='#snippet-multiplecalls' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -131,7 +129,7 @@ var settings = new VerifySettings();
settings.UseFileName("CustomFileName");
await Verify("value", settings);
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L161-L167' title='Snippet source file'>snippet source</a> | <a href='#snippet-usefilename' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L147-L153' title='Snippet source file'>snippet source</a> | <a href='#snippet-usefilename' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in `CustomFileName.verified.txt`.
@ -142,7 +140,7 @@ Will result in `CustomFileName.verified.txt`.
await Verify("value")
.UseFileName("CustomFileNameFluent");
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L182-L187' title='Snippet source file'>snippet source</a> | <a href='#snippet-usefilenamefluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L168-L173' title='Snippet source file'>snippet source</a> | <a href='#snippet-usefilenamefluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Will result in `UseFileNameFluent.verified.txt`.
@ -181,11 +179,9 @@ public class UniqueForSample
}
[Fact]
public Task RuntimeFluent()
{
return Verify("value")
public Task RuntimeFluent() =>
Verify("value")
.UniqueForRuntime();
}
[Fact]
public Task RuntimeAndVersion()
@ -204,11 +200,9 @@ public class UniqueForSample
}
[Fact]
public Task AssemblyConfigurationFluent()
{
return Verify("value")
public Task AssemblyConfigurationFluent() =>
Verify("value")
.UniqueForAssemblyConfiguration();
}
[Fact]
public Task Architecture()
@ -219,11 +213,9 @@ public class UniqueForSample
}
[Fact]
public Task ArchitectureFluent()
{
return Verify("value")
public Task ArchitectureFluent() =>
Verify("value")
.UniqueForArchitecture();
}
[Fact]
public Task OSPlatform()
@ -234,14 +226,12 @@ public class UniqueForSample
}
[Fact]
public Task OSPlatformFluent()
{
return Verify("value")
public Task OSPlatformFluent() =>
Verify("value")
.UniqueForOSPlatform();
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L1-L75' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplexunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L1-L67' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplexunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -262,11 +252,9 @@ public class UniqueForSample
}
[Test]
public Task RuntimeFluent()
{
return Verify("value")
public Task RuntimeFluent() =>
Verify("value")
.UniqueForRuntime();
}
[Test]
public Task AssemblyConfiguration()
@ -277,11 +265,9 @@ public class UniqueForSample
}
[Test]
public Task AssemblyConfigurationFluent()
{
return Verify("value")
public Task AssemblyConfigurationFluent() =>
Verify("value")
.UniqueForAssemblyConfiguration();
}
[Test]
public Task RuntimeAndVersion()
@ -292,11 +278,9 @@ public class UniqueForSample
}
[Test]
public Task RuntimeAndVersionFluent()
{
return Verify("value")
public Task RuntimeAndVersionFluent() =>
Verify("value")
.UniqueForRuntimeAndVersion();
}
[Test]
public Task Architecture()
@ -307,11 +291,9 @@ public class UniqueForSample
}
[Test]
public Task ArchitectureFluent()
{
return Verify("value")
public Task ArchitectureFluent() =>
Verify("value")
.UniqueForArchitecture();
}
[Test]
public Task OSPlatform()
@ -322,14 +304,12 @@ public class UniqueForSample
}
[Test]
public Task OSPlatformFluent()
{
return Verify("value")
public Task OSPlatformFluent() =>
Verify("value")
.UniqueForOSPlatform();
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Snippets/UniqueForSample.cs#L1-L82' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplenunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Snippets/UniqueForSample.cs#L1-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplenunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -368,11 +348,9 @@ public class UniqueForSample :
}
[TestMethod]
public Task RuntimeFluent()
{
return Verify("value")
public Task RuntimeFluent() =>
Verify("value")
.UniqueForRuntime();
}
[TestMethod]
public Task RuntimeAndVersion()
@ -383,11 +361,9 @@ public class UniqueForSample :
}
[TestMethod]
public Task RuntimeAndVersionFluent()
{
return Verify("value")
public Task RuntimeAndVersionFluent() =>
Verify("value")
.UniqueForRuntimeAndVersion();
}
[TestMethod]
public Task AssemblyConfiguration()
@ -398,11 +374,9 @@ public class UniqueForSample :
}
[TestMethod]
public Task AssemblyConfigurationFluent()
{
return Verify("value")
public Task AssemblyConfigurationFluent() =>
Verify("value")
.UniqueForAssemblyConfiguration();
}
[TestMethod]
public Task Architecture()
@ -413,11 +387,9 @@ public class UniqueForSample :
}
[TestMethod]
public Task ArchitectureFluent()
{
return Verify("value")
public Task ArchitectureFluent() =>
Verify("value")
.UniqueForArchitecture();
}
[TestMethod]
public Task OSPlatform()
@ -428,14 +400,12 @@ public class UniqueForSample :
}
[TestMethod]
public Task OSPlatformFluent()
{
return Verify("value")
public Task OSPlatformFluent() =>
Verify("value")
.UniqueForOSPlatform();
}
}
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/UniqueForSample.cs#L3-L85' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplemstest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/UniqueForSample.cs#L3-L75' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplemstest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -500,9 +470,8 @@ public class ExtensionSample
}
[Fact]
public Task AtMethodFluent()
{
return Verify(
public Task AtMethodFluent() =>
Verify(
target: @"
<note>
<to>Joe</to>
@ -511,12 +480,10 @@ public class ExtensionSample
</note>",
settings: classLevelSettings)
.UseExtension("xml");
}
[Fact]
public Task SharedClassLevelSettings()
{
return Verify(
public Task SharedClassLevelSettings() =>
Verify(
target: @"
{
fruit: 'Apple',
@ -524,10 +491,9 @@ public class ExtensionSample
color: 'Red'
}",
settings: classLevelSettings);
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.cs#L1-L57' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitextensionsample' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.cs#L1-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitextensionsample' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result in two files:
@ -567,7 +533,7 @@ To access the current Namer `Runtime` or `RuntimeAndVersion` strings use:
Debug.WriteLine(Namer.Runtime);
Debug.WriteLine(Namer.RuntimeAndVersion);
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L262-L267' title='Snippet source file'>snippet source</a> | <a href='#snippet-accessnamerruntimeandversion' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L248-L253' title='Snippet source file'>snippet source</a> | <a href='#snippet-accessnamerruntimeandversion' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -46,13 +46,11 @@ public Task InlineDataUsage(string arg)
[Theory]
[InlineData("Value1")]
[InlineData("Value2")]
public Task InlineDataUsageFluent(string arg)
{
return Verify(arg)
public Task InlineDataUsageFluent(string arg) =>
Verify(arg)
.UseParameters(arg);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L33-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitinlinedata' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L27-L46' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitinlinedata' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -72,11 +70,9 @@ public Task MemberDataUsage(string arg)
[Theory]
[MemberData(nameof(GetData))]
public Task MemberDataUsageFluent(string arg)
{
return Verify(arg)
public Task MemberDataUsageFluent(string arg) =>
Verify(arg)
.UseParameters(arg);
}
public static IEnumerable<object[]> GetData()
{
@ -84,7 +80,7 @@ public static IEnumerable<object[]> GetData()
yield return new object[] {"Value2"};
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L56-L81' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitmemberdata' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L48-L71' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitmemberdata' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -116,11 +112,9 @@ public class ComplexParametersSample
[Theory]
[MemberData(nameof(GetComplexMemberData))]
public Task ComplexMemberDataFluent(ComplexData arg)
{
return Verify(arg)
public Task ComplexMemberDataFluent(ComplexData arg) =>
Verify(arg)
.UseParameters(arg);
}
[Theory]
[MemberData(nameof(GetComplexMemberData))]
@ -133,11 +127,9 @@ public class ComplexParametersSample
[Theory]
[MemberData(nameof(GetComplexMemberData))]
public Task ComplexMemberNullableDataFluent(ComplexData? arg)
{
return Verify(arg)
public Task ComplexMemberNullableDataFluent(ComplexData? arg) =>
Verify(arg)
.UseParameters(arg);
}
public static IEnumerable<object[]> GetComplexMemberData()
{
@ -167,11 +159,9 @@ public class ComplexParametersSample
[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
public Task ComplexMemberStructDataFluent(ComplexStructData arg)
{
return Verify(arg)
public Task ComplexMemberStructDataFluent(ComplexStructData arg) =>
Verify(arg)
.UseParameters(arg);
}
[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
@ -184,11 +174,9 @@ public class ComplexParametersSample
[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
public Task ComplexMemberNullableStructDataFluent(ComplexStructData? arg)
{
return Verify(arg)
public Task ComplexMemberNullableStructDataFluent(ComplexStructData? arg) =>
Verify(arg)
.UseParameters(arg);
}
public static IEnumerable<object[]> GetComplexMemberStructData()
{
@ -204,16 +192,14 @@ public class ComplexParametersSample
public struct ComplexStructData
{
public ComplexStructData(string value)
{
public ComplexStructData(string value) =>
Value = value;
}
public string Value { get; set; } = null!;
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L1-L121' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitcomplexmemberdata' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L1-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitcomplexmemberdata' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
`VerifierSettings.NameForParameter` is required since the parameter type has no `ToString()` override that can be used for deriving the name of the `.verified.` file.
@ -229,12 +215,10 @@ public class ComplexParametersSample
```cs
[TestCase("Value1")]
[TestCase("Value2")]
public Task TestCaseUsage(string arg)
{
return Verify(arg);
}
public Task TestCaseUsage(string arg) =>
Verify(arg);
```
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ParametersSample.cs#L25-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-nunittestcase' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ParametersSample.cs#L19-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-nunittestcase' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -265,14 +249,12 @@ public class ParametersSample :
[DataTestMethod]
[DataRow("Value1")]
[DataRow("Value2")]
public Task DataRowUsageFluent(string arg)
{
return Verify(arg)
public Task DataRowUsageFluent(string arg) =>
Verify(arg)
.UseParameters(arg);
}
}
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L3-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-mstestdatarow' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L3-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-mstestdatarow' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -300,13 +282,11 @@ public Task UseTextForParameters(string arg)
[Theory]
[InlineData("Value1")]
[InlineData("Value2")]
public Task UseTextForParametersFluent(string arg)
{
return Verify(arg)
public Task UseTextForParametersFluent(string arg) =>
Verify(arg)
.UseTextForParameters(arg);
}
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L300-L321' title='Snippet source file'>snippet source</a> | <a href='#snippet-usetextforparameters' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L282-L301' title='Snippet source file'>snippet source</a> | <a href='#snippet-usetextforparameters' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in:
@ -336,13 +316,11 @@ public async Task IgnoreParametersForVerified(string arg)
[Theory]
[InlineData("One")]
[InlineData("Two")]
public async Task IgnoreParametersForVerifiedFluent(string arg)
{
public async Task IgnoreParametersForVerifiedFluent(string arg) =>
await Verify("value")
.IgnoreParametersForVerified(arg);
}
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L370-L391' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoreparametersforverified' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L344-L363' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoreparametersforverified' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in:

Просмотреть файл

@ -56,7 +56,7 @@ For example remove lines containing `text`:
```cs
verifySettings.ScrubLines(line => line.Contains("text"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L948-L952' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublines' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L906-L910' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublines' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -71,7 +71,7 @@ For example remove lines containing `text1` or `text2`
```cs
verifySettings.ScrubLinesContaining("text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L954-L958' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublinescontaining' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L912-L916' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublinescontaining' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Case insensitive by default (StringComparison.OrdinalIgnoreCase).
@ -83,7 +83,7 @@ Case insensitive by default (StringComparison.OrdinalIgnoreCase).
```cs
verifySettings.ScrubLinesContaining(StringComparison.Ordinal, "text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L960-L964' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublinescontainingordinal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L918-L922' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublinescontainingordinal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -98,7 +98,7 @@ For example converts lines to upper case:
```cs
verifySettings.ScrubLinesWithReplace(line => line.ToUpper());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L966-L970' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublineswithreplace' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L924-L928' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrublineswithreplace' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -111,7 +111,7 @@ Replaces `Environment.MachineName` with `TheMachineName`.
```cs
verifySettings.ScrubMachineName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L972-L976' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmachinename' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L930-L934' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmachinename' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -163,9 +163,8 @@ public class ScrubbersSample
}
[Fact]
public Task LinesFluent()
{
return Verify(
public Task LinesFluent() =>
Verify(
target: @"
LineA
LineB
@ -189,7 +188,6 @@ public class ScrubbersSample
.ScrubLines(removeLine: line => line.Contains("J"))
.ScrubLinesContaining("b", "D")
.ScrubLinesContaining(StringComparison.Ordinal, "H");
}
[Fact]
public Task AfterSerialization()
@ -219,9 +217,8 @@ public class ScrubbersSample
}
[Fact]
public Task RemoveOrReplace()
{
return Verify(
public Task RemoveOrReplace() =>
Verify(
target: @"
LineA
LineB
@ -237,22 +234,19 @@ public class ScrubbersSample
return line.ToLower();
});
}
[Fact]
public Task EmptyLines()
{
return Verify(
public Task EmptyLines() =>
Verify(
target: @"
LineA
LineC
")
.ScrubEmptyLines();
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L127' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplexunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L121' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplexunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -296,9 +290,8 @@ public class ScrubbersSample
}
[Test]
public Task LinesFluent()
{
return Verify(
public Task LinesFluent() =>
Verify(
target: @"
LineA
LineB
@ -322,7 +315,6 @@ public class ScrubbersSample
.ScrubLines(removeLine: line => line.Contains("J"))
.ScrubLinesContaining("b", "D")
.ScrubLinesContaining(StringComparison.Ordinal, "H");
}
[Test]
public Task AfterSerialization()
@ -352,9 +344,8 @@ public class ScrubbersSample
}
[Test]
public Task RemoveOrReplace()
{
return Verify(
public Task RemoveOrReplace() =>
Verify(
target: @"
LineA
LineB
@ -370,22 +361,19 @@ public class ScrubbersSample
return line.ToLower();
});
}
[Test]
public Task EmptyLines()
{
return Verify(
public Task EmptyLines() =>
Verify(
target: @"
LineA
LineC
")
.ScrubEmptyLines();
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubbersSample.cs#L1-L127' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplenunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubbersSample.cs#L1-L121' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplenunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -430,9 +418,8 @@ public class ScrubbersSample :
}
[TestMethod]
public Task LinesFluent()
{
return Verify(
public Task LinesFluent() =>
Verify(
target: @"
LineA
LineB
@ -456,7 +443,6 @@ public class ScrubbersSample :
.ScrubLines(removeLine: line => line.Contains("J"))
.ScrubLinesContaining("b", "D")
.ScrubLinesContaining(StringComparison.Ordinal, "H");
}
[TestMethod]
public Task AfterSerialization()
@ -486,9 +472,8 @@ public class ScrubbersSample :
}
[TestMethod]
public Task RemoveOrReplace()
{
return Verify(
public Task RemoveOrReplace() =>
Verify(
target: @"
LineA
LineB
@ -504,22 +489,19 @@ public class ScrubbersSample :
return line.ToLower();
});
}
[TestMethod]
public Task EmptyLines()
{
return Verify(
public Task EmptyLines() =>
Verify(
target: @"
LineA
LineC
")
.ScrubEmptyLines();
}
}
```
<sup><a href='/src/Verify.MSTest.Tests/Scrubbers/ScrubbersSample.cs#L3-L130' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplemstest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Scrubbers/ScrubbersSample.cs#L3-L124' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplemstest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -581,20 +563,16 @@ public class ScrubberLevelsSample
}
[Fact]
public Task UsageFluent()
{
return Verify("One Two Three", classLevelSettings)
public Task UsageFluent() =>
Verify("One Two Three", classLevelSettings)
.AddScrubber(s => s.Replace("Two", "B"));
}
[ModuleInitializer]
public static void Initialize()
{
public static void Initialize() =>
VerifierSettings.AddScrubber(s => s.Replace("One", "A"));
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplexunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplexunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -623,20 +601,16 @@ public class ScrubberLevelsSample
}
[Test]
public Task SimpleFluent()
{
return Verify("One Two Three", classLevelSettings)
public Task SimpleFluent() =>
Verify("One Two Three", classLevelSettings)
.AddScrubber(s => s.Replace("Two", "B"));
}
[OneTimeSetUp]
public static void Setup()
{
public static void Setup() =>
VerifierSettings.AddScrubber(s => s.Replace("One", "A"));
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplenunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplenunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -666,20 +640,16 @@ public class ScrubberLevelsSample :
}
[TestMethod]
public Task SimpleFluent()
{
return Verify("One Two Three", classLevelSettings)
public Task SimpleFluent() =>
Verify("One Two Three", classLevelSettings)
.AddScrubber(s => s.Replace("Two", "B"));
}
[AssemblyInitialize]
public static void Setup(TestContext testContext)
{
public static void Setup(TestContext testContext) =>
VerifierSettings.AddScrubber(s => s.Replace("One", "A"));
}
}
```
<sup><a href='/src/Verify.MSTest.Tests/Scrubbers/ScrubberLevelsSample.cs#L3-L39' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplemstest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Scrubbers/ScrubberLevelsSample.cs#L3-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplemstest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Просмотреть файл

@ -53,7 +53,7 @@ var target = new TheTarget
};
await Verify(target);
```
<sup><a href='/src/StrictJsonTests/Tests.cs#L42-L50' title='Snippet source file'>snippet source</a> | <a href='#snippet-usestrictjsonverify' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/StrictJsonTests/Tests.cs#L38-L46' title='Snippet source file'>snippet source</a> | <a href='#snippet-usestrictjsonverify' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
The resulting file will be:
@ -84,7 +84,7 @@ var settings = new JsonSerializerSettings
Culture = CultureInfo.InvariantCulture
};
```
<sup><a href='/src/Verify/Serialization/SerializationSettings.cs#L100-L110' title='Snippet source file'>snippet source</a> | <a href='#snippet-defaultserialization' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify/Serialization/SerializationSettings.cs#L92-L102' title='Snippet source file'>snippet source</a> | <a href='#snippet-defaultserialization' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -100,7 +100,7 @@ VerifierSettings.ModifySerialization(settings =>
settings.AddExtraSettings(serializerSettings =>
serializerSettings.TypeNameHandling = TypeNameHandling.All));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L281-L287' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L269-L275' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -121,7 +121,7 @@ public Task AddExtraSettings()
return Verify(target, verifySettings);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L246-L260' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettings' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L234-L248' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettings' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -141,7 +141,7 @@ public Task AddExtraSettingsFluent()
serializerSettings.DefaultValueHandling = DefaultValueHandling.Include));
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L262-L275' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L250-L263' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextrasettingsfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -161,7 +161,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontIgnoreEmptyCollections());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L818-L822' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L784-L788' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -183,7 +183,7 @@ var target = new GuidTarget
await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1163-L1176' title='Snippet source file'>snippet source</a> | <a href='#snippet-guid' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1107-L1120' title='Snippet source file'>snippet source</a> | <a href='#snippet-guid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in the following:
@ -208,7 +208,7 @@ Strings containing inline Guids can also be scrubbed. To enable this behavior, u
```cs
VerifierSettings.ScrubInlineGuids();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L854-L858' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L820-L824' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -223,7 +223,7 @@ var settings = new VerifySettings();
settings.ModifySerialization(_ => _.DontScrubGuids());
await Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L418-L424' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguids' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L406-L412' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguids' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or with the fluent api:
@ -234,7 +234,7 @@ Or with the fluent api:
await Verify(target)
.ModifySerialization(_ => _.DontScrubGuids());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L432-L437' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L420-L425' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
To disable this behavior globally use:
@ -244,7 +244,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontScrubGuids());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L827-L831' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L793-L797' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubguidsglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -272,7 +272,7 @@ var target = new DateTimeTarget
await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L639-L658' title='Snippet source file'>snippet source</a> | <a href='#snippet-date' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L613-L632' title='Snippet source file'>snippet source</a> | <a href='#snippet-date' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in the following:
@ -310,7 +310,7 @@ settings.ModifySerialization(_ => _.DontScrubDateTimes());
return Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L890-L902' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L850-L862' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or using the fluent api use:
@ -326,7 +326,7 @@ var target = new
return Verify(target)
.ModifySerialization(_ => _.DontScrubDateTimes());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L907-L917' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L867-L877' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally use:
@ -336,7 +336,7 @@ Or globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontScrubDateTimes());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L922-L926' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L882-L886' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -362,7 +362,7 @@ public Task NumericIdScrubbing()
return Verify(target);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L371-L388' title='Snippet source file'>snippet source</a> | <a href='#snippet-numericid' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L359-L376' title='Snippet source file'>snippet source</a> | <a href='#snippet-numericid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in the following:
@ -403,7 +403,7 @@ public Task TreatAsNumericId()
member => member.Name == "TheProperty"));
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L290-L305' title='Snippet source file'>snippet source</a> | <a href='#snippet-treatasnumericid' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L278-L293' title='Snippet source file'>snippet source</a> | <a href='#snippet-treatasnumericid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
To define a convention globally use:
@ -415,7 +415,7 @@ VerifierSettings.ModifySerialization(
settings => settings.TreatAsNumericId(
member => member.Name == "TheProperty"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L311-L317' title='Snippet source file'>snippet source</a> | <a href='#snippet-treatasnumericidglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L299-L305' title='Snippet source file'>snippet source</a> | <a href='#snippet-treatasnumericidglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -441,7 +441,7 @@ public Task NumericIdScrubbingDisabled()
.ModifySerialization(_ => _.DontScrubNumericIds());
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L352-L369' title='Snippet source file'>snippet source</a> | <a href='#snippet-disablenumericid' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L340-L357' title='Snippet source file'>snippet source</a> | <a href='#snippet-disablenumericid' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
To disable this behavior globally use:
@ -451,7 +451,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontScrubNumericIds());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L334-L338' title='Snippet source file'>snippet source</a> | <a href='#snippet-disablenumericidglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L322-L326' title='Snippet source file'>snippet source</a> | <a href='#snippet-disablenumericidglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -466,7 +466,7 @@ To disable this behavior globally use:
```cs
VerifierSettings.ModifySerialization(_ => _.DontIgnoreFalse());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L931-L935' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignorefalse' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L891-L895' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontignorefalse' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -560,13 +560,11 @@ One common use case is to register a custom [JsonConverter](https://www.newtonso
class CompanyConverter :
WriteOnlyJsonConverter<Company>
{
public override void Write(VerifyJsonWriter writer, Company company)
{
public override void Write(VerifyJsonWriter writer, Company company) =>
writer.WriteProperty(company, company.Name, "Name");
}
}
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L144-L155' title='Snippet source file'>snippet source</a> | <a href='#snippet-companyconverter' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L144-L153' title='Snippet source file'>snippet source</a> | <a href='#snippet-companyconverter' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
<!-- snippet: JsonConverter -->
@ -622,7 +620,7 @@ public Task ScopedSerializerFluent()
.AddExtraSettings(_ => _.TypeNameHandling = TypeNameHandling.All);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2182-L2209' title='Snippet source file'>snippet source</a> | <a href='#snippet-scopedserializer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2106-L2133' title='Snippet source file'>snippet source</a> | <a href='#snippet-scopedserializer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -716,7 +714,7 @@ public Task IgnoreTypeFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1484-L1555' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretype' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1422-L1493' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretype' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -727,7 +725,7 @@ Or globally:
VerifierSettings.ModifySerialization(
_ => _.IgnoreMembersWithType<ToIgnore>());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1476-L1481' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretypeglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1414-L1419' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoretypeglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -803,7 +801,7 @@ public Task AddIgnoreInstanceFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1417-L1461' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1355-L1399' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -814,7 +812,7 @@ Or globally:
VerifierSettings.ModifySerialization(
_ => _.IgnoreInstance<Instance>(x => x.Property == "Ignore"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1409-L1414' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstanceglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1347-L1352' title='Snippet source file'>snippet source</a> | <a href='#snippet-addignoreinstanceglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -857,7 +855,7 @@ public Task WithObsoleteProp()
return Verify(target);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2144-L2164' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2070-L2090' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -905,7 +903,7 @@ public Task WithObsoletePropIncludedFluent()
.ModifySerialization(_ => _.IncludeObsoletes());
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2115-L2142' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2041-L2068' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -915,7 +913,7 @@ Or globally:
```cs
VerifierSettings.ModifySerialization(_ => _.IncludeObsoletes());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2108-L2112' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincludedglobally' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2034-L2038' title='Snippet source file'>snippet source</a> | <a href='#snippet-withobsoletepropincludedglobally' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -980,7 +978,7 @@ public Task IgnoreMemberByExpressionFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1716-L1759' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1642-L1685' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally
@ -997,7 +995,7 @@ VerifierSettings.ModifySerialization(_ =>
_.IgnoreMember<IgnoreExplicitTarget>(x => x.PropertyThatThrows);
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1702-L1713' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1628-L1639' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1075,7 +1073,7 @@ public Task IgnoreMemberByNameFluent()
});
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1815-L1872' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1741-L1798' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1098,7 +1096,7 @@ VerifierSettings.ModifySerialization(_ =>
_.IgnoreMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1795-L1812' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbynameglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1721-L1738' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorememberbynameglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1145,7 +1143,7 @@ public Task CustomExceptionPropFluent()
.ModifySerialization(_ => _.IgnoreMembersThatThrow<CustomException>());
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2003-L2022' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1929-L1948' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1155,7 +1153,7 @@ Or globally:
```cs
VerifierSettings.ModifySerialization(_ => _.IgnoreMembersThatThrow<CustomException>());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1996-L2000' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1922-L1926' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1194,7 +1192,7 @@ public Task ExceptionMessagePropFluent()
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1354-L1377' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1292-L1315' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Or globally:
@ -1205,7 +1203,7 @@ Or globally:
VerifierSettings.ModifySerialization(
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1346-L1351' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpressionglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1284-L1289' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpressionglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Result:
@ -1363,7 +1361,7 @@ public Task MemberConverterByExpression()
return Verify(input);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1761-L1785' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverter' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1687-L1711' title='Snippet source file'>snippet source</a> | <a href='#snippet-memberconverter' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -1377,13 +1375,11 @@ Serialized properties can optionally be sorted alphabetically, ie ignoring the o
static class ModuleInitializer
{
[ModuleInitializer]
public static void Init()
{
public static void Init() =>
VerifierSettings.SortPropertiesAlphabetically();
}
}
```
<sup><a href='/src/SortedPropertiesTests/SortedPropertiesTests.cs#L3-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-sortproperties' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/SortedPropertiesTests/SortedPropertiesTests.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-sortproperties' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -1416,12 +1412,10 @@ When when content is verified:
<a id='snippet-jsonappender'></a>
```cs
[Fact]
public Task WithJsonAppender()
{
return Verify("TheValue");
}
public Task WithJsonAppender() =>
Verify("TheValue");
```
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L41-L49' title='Snippet source file'>snippet source</a> | <a href='#snippet-jsonappender' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L35-L41' title='Snippet source file'>snippet source</a> | <a href='#snippet-jsonappender' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
The content from RegisterJsonAppender will be included in the output:
@ -1443,12 +1437,10 @@ If the target is a stream or binary file:
<a id='snippet-jsonappenderstream'></a>
```cs
[Fact]
public Task Stream()
{
return Verify(IoHelpers.OpenRead("sample.txt"));
}
public Task Stream() =>
Verify(IoHelpers.OpenRead("sample.txt"));
```
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L74-L82' title='Snippet source file'>snippet source</a> | <a href='#snippet-jsonappenderstream' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L60-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-jsonappenderstream' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Then the appended content will be added to the `*.00.verified.txt` file:

Просмотреть файл

@ -54,9 +54,8 @@ Given a class to be tested:
```cs
public static class ClassBeingTested
{
public static Person FindPerson()
{
return new()
public static Person FindPerson() =>
new()
{
Id = new("ebced679-45d3-4653-8791-3d969c4a986c"),
Title = Title.Mr,
@ -74,10 +73,9 @@ public static class ClassBeingTested
Country = "USA"
}
};
}
}
```
<sup><a href='/src/TargetLibrary/ClassBeingTested.cs#L1-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-classbeingtested' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/TargetLibrary/ClassBeingTested.cs#L1-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-classbeingtested' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
@ -234,9 +232,8 @@ If the implementation of `ClassBeingTested` changes:
```cs
public static class ClassBeingTested
{
public static Person FindPerson()
{
return new()
public static Person FindPerson() =>
new()
{
Id = new("ebced679-45d3-4653-8791-3d969c4a986c"),
Title = Title.Mr,
@ -256,10 +253,9 @@ public static class ClassBeingTested
Country = "USA"
}
};
}
}
```
<sup><a href='/src/TargetLibrary/ClassBeingTestedChanged.cs#L3-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-classbeingtestedchanged' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/TargetLibrary/ClassBeingTestedChanged.cs#L3-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-classbeingtestedchanged' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
And the test is re run it will fail.
@ -306,7 +302,7 @@ public Task VerifyJsonJToken()
return VerifyJson(target);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1934-L1959' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyjson' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1860-L1885' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifyjson' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Results in:
@ -343,22 +339,18 @@ When modifying settings at the both global level it should be done using a Modul
public class StaticSettings
{
[Fact]
public Task Test()
{
return Verify("String to verify");
}
public Task Test() =>
Verify("String to verify");
}
public static class StaticSettingsUsage
{
[ModuleInitializer]
public static void Initialize()
{
public static void Initialize() =>
VerifierSettings.AddScrubber(_ => _.Replace("String to verify", "new value"));
}
}
```
<sup><a href='/src/Verify.Tests/StaticSettings.cs#L1-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-StaticSettings.cs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/StaticSettings.cs#L1-L14' title='Snippet source file'>snippet source</a> | <a href='#snippet-StaticSettings.cs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->