зеркало из https://github.com/VerifyTests/Verify.git
This commit is contained in:
Родитель
c04033ebbb
Коммит
fa93a7e784
|
@ -12,8 +12,8 @@ When validating multiple instances, an [anonymous type](https://docs.microsoft.c
|
|||
|
||||
## NUnit
|
||||
|
||||
<!-- snippet: anonNUnit -->
|
||||
<a id='snippet-anonnunit'></a>
|
||||
<!-- snippet: AnonNUnit -->
|
||||
<a id='snippet-AnonNUnit'></a>
|
||||
```cs
|
||||
[Test]
|
||||
public Task Anon()
|
||||
|
@ -37,14 +37,14 @@ public Task Anon()
|
|||
});
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.NUnit.Tests/VerifyObjectSamples.cs#L42-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-anonnunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.NUnit.Tests/VerifyObjectSamples.cs#L42-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-AnonNUnit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## xUnit
|
||||
|
||||
<!-- snippet: anonXunit -->
|
||||
<a id='snippet-anonxunit'></a>
|
||||
<!-- snippet: AnonXunit -->
|
||||
<a id='snippet-AnonXunit'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Anon()
|
||||
|
@ -68,14 +68,14 @@ public Task Anon()
|
|||
});
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.cs#L23-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-anonxunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.cs#L23-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-AnonXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## Fixie
|
||||
|
||||
<!-- snippet: anonFixie -->
|
||||
<a id='snippet-anonfixie'></a>
|
||||
<!-- snippet: AnonFixie -->
|
||||
<a id='snippet-AnonFixie'></a>
|
||||
```cs
|
||||
public Task Anon()
|
||||
{
|
||||
|
@ -98,14 +98,14 @@ public Task Anon()
|
|||
});
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Fixie.Tests/VerifyObjectSamples.cs#L39-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-anonfixie' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Fixie.Tests/VerifyObjectSamples.cs#L39-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-AnonFixie' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## MSTest
|
||||
|
||||
<!-- snippet: anonMSTest -->
|
||||
<a id='snippet-anonmstest'></a>
|
||||
<!-- snippet: AnonMSTest -->
|
||||
<a id='snippet-AnonMSTest'></a>
|
||||
```cs
|
||||
[TestMethod]
|
||||
public Task Anon()
|
||||
|
@ -129,7 +129,7 @@ public Task Anon()
|
|||
});
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.MSTest.Tests/VerifyObjectSamples.cs#L27-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-anonmstest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.MSTest.Tests/VerifyObjectSamples.cs#L27-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-AnonMSTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -13,14 +13,14 @@ Allows extra files to be verified in addition to the primary target.
|
|||
## AppendFile
|
||||
|
||||
<!-- snippet: AppendFile -->
|
||||
<a id='snippet-appendfile'></a>
|
||||
<a id='snippet-AppendFile'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task AppendFile() =>
|
||||
Verify("Foo", settings)
|
||||
.AppendFile("sample.png");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L20-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-appendfile' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L20-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-AppendFile' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Will result in two files being verified:
|
||||
|
@ -32,14 +32,14 @@ Will result in two files being verified:
|
|||
## AppendContentAsFile
|
||||
|
||||
<!-- snippet: AppendContentAsFile -->
|
||||
<a id='snippet-appendcontentasfile'></a>
|
||||
<a id='snippet-AppendContentAsFile'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task AppendContentAsFile() =>
|
||||
Verify("Foo")
|
||||
.AppendContentAsFile("extra content");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L29-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-appendcontentasfile' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L29-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-AppendContentAsFile' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Will result in two files being verified:
|
||||
|
|
|
@ -12,7 +12,7 @@ Binary data can be verified by passing a stream.
|
|||
To know how to treat the stream, an extension needs to be provided:
|
||||
|
||||
<!-- snippet: StreamWithExtension -->
|
||||
<a id='snippet-streamwithextension'></a>
|
||||
<a id='snippet-StreamWithExtension'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task StreamWithExtension()
|
||||
|
@ -21,19 +21,19 @@ public Task StreamWithExtension()
|
|||
return Verify(stream, "png");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/StreamTests.cs#L91-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-streamwithextension' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/StreamTests.cs#L91-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-StreamWithExtension' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
For a `FileStream` the extension is not required:
|
||||
|
||||
<!-- snippet: FileStream -->
|
||||
<a id='snippet-filestream'></a>
|
||||
<a id='snippet-FileStream'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task FileStream() =>
|
||||
Verify(File.OpenRead("sample.txt"));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/StreamTests.cs#L102-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-filestream' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/StreamTests.cs#L102-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-FileStream' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ In some scenarios, as part of a build, the test assemblies are copied to a diffe
|
|||
For example a possible implementation for [AppVeyor](https://www.appveyor.com/) could be:
|
||||
|
||||
<!-- snippet: DerivePathInfoAppVeyor -->
|
||||
<a id='snippet-derivepathinfoappveyor'></a>
|
||||
<a id='snippet-DerivePathInfoAppVeyor'></a>
|
||||
```cs
|
||||
if (BuildServerDetector.Detected)
|
||||
{
|
||||
|
@ -100,5 +100,5 @@ if (BuildServerDetector.Detected)
|
|||
});
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L86-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-derivepathinfoappveyor' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L86-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-DerivePathInfoAppVeyor' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
|
|
@ -21,11 +21,11 @@ Clipboard support is shipped via the [Verify.ClipboardAccept nuget](https://www.
|
|||
The clipboard behavior can be enabled using the following:
|
||||
|
||||
<!-- snippet: EnableClipboard -->
|
||||
<a id='snippet-enableclipboard'></a>
|
||||
<a id='snippet-EnableClipboard'></a>
|
||||
```cs
|
||||
ClipboardAccept.Enable();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L31-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-enableclipboard' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L31-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-EnableClipboard' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ Given the following method:
|
|||
### Class being tested
|
||||
|
||||
<!-- snippet: ClassBeingTested -->
|
||||
<a id='snippet-classbeingtested'></a>
|
||||
<a id='snippet-ClassBeingTested'></a>
|
||||
```cs
|
||||
public static class ClassBeingTested
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ public static class ClassBeingTested
|
|||
};
|
||||
}
|
||||
```
|
||||
<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>
|
||||
<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 -->
|
||||
|
||||
|
||||
|
@ -63,7 +63,7 @@ Compare a traditional assertion based test to a verification test.
|
|||
#### Traditional assertion test:
|
||||
|
||||
<!-- snippet: TraditionalTest -->
|
||||
<a id='snippet-traditionaltest'></a>
|
||||
<a id='snippet-TraditionalTest'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public void TraditionalTest()
|
||||
|
@ -81,14 +81,14 @@ public void TraditionalTest()
|
|||
Assert.Equal("USA", person.Address.Country);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L3-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-traditionaltest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L3-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-TraditionalTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
#### Snapshot test
|
||||
|
||||
<!-- snippet: SnapshotTest -->
|
||||
<a id='snippet-snapshottest'></a>
|
||||
<a id='snippet-SnapshotTest'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task SnapshotTest()
|
||||
|
@ -97,7 +97,7 @@ public Task SnapshotTest()
|
|||
return Verify(person);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L23-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-snapshottest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L23-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-SnapshotTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Produces a snapshot file `SnapshotTest.verified.txt`:
|
||||
|
|
|
@ -17,7 +17,7 @@ Using a custom comparer can be helpful when a result has changed, but not enough
|
|||
For samples purposes only the image sizes will be compared:
|
||||
|
||||
<!-- snippet: ImageComparer -->
|
||||
<a id='snippet-imagecomparer'></a>
|
||||
<a id='snippet-ImageComparer'></a>
|
||||
```cs
|
||||
static Task<CompareResult> CompareImages(
|
||||
Stream received,
|
||||
|
@ -34,7 +34,7 @@ static Task<CompareResult> CompareImages(
|
|||
return Task.FromResult(result);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L34-L51' 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#L34-L51' 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.
|
||||
|
@ -45,7 +45,7 @@ The returned `CompareResult.NotEqual` takes an optional message that will be ren
|
|||
### Instance comparer
|
||||
|
||||
<!-- snippet: InstanceComparer -->
|
||||
<a id='snippet-instancecomparer'></a>
|
||||
<a id='snippet-InstanceComparer'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task InstanceComparer()
|
||||
|
@ -60,28 +60,28 @@ public Task InstanceComparerFluent() =>
|
|||
VerifyFile("sample.png")
|
||||
.UseStreamComparer(CompareImages);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L5-L20' 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#L5-L20' title='Snippet source file'>snippet source</a> | <a href='#snippet-InstanceComparer' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Static comparer
|
||||
|
||||
<!-- snippet: StaticComparer -->
|
||||
<a id='snippet-staticcomparer'></a>
|
||||
<a id='snippet-StaticComparer'></a>
|
||||
```cs
|
||||
VerifierSettings.RegisterStreamComparer(
|
||||
extension: "png",
|
||||
compare: CompareImages);
|
||||
await VerifyFile("TheImage.png");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L24-L31' 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#L24-L31' title='Snippet source file'>snippet source</a> | <a href='#snippet-StaticComparer' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## Default Comparison
|
||||
|
||||
<!-- snippet: DefualtCompare -->
|
||||
<a id='snippet-defualtcompare'></a>
|
||||
<a id='snippet-DefualtCompare'></a>
|
||||
```cs
|
||||
const int bufferSize = 1024 * sizeof(long);
|
||||
|
||||
|
@ -143,7 +143,7 @@ static async Task<int> ReadBufferAsync(Stream stream, byte[] buffer)
|
|||
return bytesRead;
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify/Compare/StreamComparer.cs#L3-L65' title='Snippet source file'>snippet source</a> | <a href='#snippet-defualtcompare' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify/Compare/StreamComparer.cs#L3-L65' title='Snippet source file'>snippet source</a> | <a href='#snippet-DefualtCompare' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ Multiple png files:
|
|||
This sample uses a typed approach. So the converter acts on an in memory instance matching based on type.
|
||||
|
||||
<!-- snippet: RegisterFileConverterType -->
|
||||
<a id='snippet-registerfileconvertertype'></a>
|
||||
<a id='snippet-RegisterFileConverterType'></a>
|
||||
```cs
|
||||
VerifierSettings.RegisterFileConverter<Image>(
|
||||
|
||||
|
@ -78,26 +78,26 @@ VerifierSettings.RegisterFileConverter<Image>(
|
|||
targets);
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L10-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerfileconvertertype' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L10-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-RegisterFileConverterType' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: FileConverterTypeVerify -->
|
||||
<a id='snippet-fileconvertertypeverify'></a>
|
||||
<a id='snippet-FileConverterTypeVerify'></a>
|
||||
```cs
|
||||
using var stream = File.OpenRead("sample.tif");
|
||||
await Verify(Image.FromStream(stream));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L49-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-fileconvertertypeverify' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L49-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-FileConverterTypeVerify' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Note that this sample also uses the optional `canConvert` to ensure that only `Image`s that are tiffs are converted.
|
||||
|
||||
<!-- snippet: ConverterCanConvert -->
|
||||
<a id='snippet-convertercanconvert'></a>
|
||||
<a id='snippet-ConverterCanConvert'></a>
|
||||
```cs
|
||||
canConvert: (target, context) => Equals(target.RawFormat, ImageFormat.Tiff),
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L14-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-convertercanconvert' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L14-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-ConverterCanConvert' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ canConvert: (target, context) => Equals(target.RawFormat, ImageFormat.Tiff),
|
|||
This sample uses a extension approach. So the converter acts on a file or stream based on the extension (configured or detected).
|
||||
|
||||
<!-- snippet: RegisterFileConverterExtension -->
|
||||
<a id='snippet-registerfileconverterextension'></a>
|
||||
<a id='snippet-RegisterFileConverterExtension'></a>
|
||||
```cs
|
||||
VerifierSettings.RegisterFileConverter(
|
||||
fromExtension: "tif",
|
||||
|
@ -134,15 +134,15 @@ VerifierSettings.RegisterFileConverter(
|
|||
targets);
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L60-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerfileconverterextension' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L60-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-RegisterFileConverterExtension' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: FileConverterExtensionVerify -->
|
||||
<a id='snippet-fileconverterextensionverify'></a>
|
||||
<a id='snippet-FileConverterExtensionVerify'></a>
|
||||
```cs
|
||||
await VerifyFile("sample.tif");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L94-L98' title='Snippet source file'>snippet source</a> | <a href='#snippet-fileconverterextensionverify' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L94-L98' title='Snippet source file'>snippet source</a> | <a href='#snippet-FileConverterExtensionVerify' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -151,7 +151,7 @@ await VerifyFile("sample.tif");
|
|||
If cleanup needs to occur after verification a callback can be passes to `ConversionResult`:
|
||||
|
||||
<!-- snippet: ConversionResultWithCleanup -->
|
||||
<a id='snippet-conversionresultwithcleanup'></a>
|
||||
<a id='snippet-ConversionResultWithCleanup'></a>
|
||||
```cs
|
||||
return new(
|
||||
info: null,
|
||||
|
@ -163,7 +163,7 @@ return new(
|
|||
return Task.CompletedTask;
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Converters/TypeConverterTests.cs#L32-L44' 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#L32-L44' title='Snippet source file'>snippet source</a> | <a href='#snippet-ConversionResultWithCleanup' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ To change this file edit the source file and then run MarkdownSnippets.
|
|||
By default dates and times (`DateTime`, `DateTimeOffset`, `DateOnly`, and `TimeOnly`) are sanitized during verification. This is done by finding each date and taking a counter based that that specific date. That counter is then used replace the date values. This allows for repeatable tests when date values are changing.
|
||||
|
||||
<!-- snippet: Date -->
|
||||
<a id='snippet-date'></a>
|
||||
<a id='snippet-Date'></a>
|
||||
```cs
|
||||
var dateTime = DateTime.Now;
|
||||
var dateTimeOffset = DateTimeOffset.Now;
|
||||
|
@ -30,7 +30,7 @@ var target = new DateTimeTarget
|
|||
|
||||
await Verify(target);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1056-L1075' 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#L1056-L1075' title='Snippet source file'>snippet source</a> | <a href='#snippet-Date' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in the following:
|
||||
|
@ -59,7 +59,7 @@ To disable this behavior use:
|
|||
### Instance
|
||||
|
||||
<!-- snippet: DontScrubDateTimes -->
|
||||
<a id='snippet-dontscrubdatetimes'></a>
|
||||
<a id='snippet-DontScrubDateTimes'></a>
|
||||
```cs
|
||||
var target = new
|
||||
{
|
||||
|
@ -71,14 +71,14 @@ settings.DontScrubDateTimes();
|
|||
|
||||
return Verify(target, settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1688-L1700' 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#L1688-L1700' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimes' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fluent
|
||||
|
||||
<!-- snippet: DontScrubDateTimesFluent -->
|
||||
<a id='snippet-dontscrubdatetimesfluent'></a>
|
||||
<a id='snippet-DontScrubDateTimesFluent'></a>
|
||||
```cs
|
||||
var target = new
|
||||
{
|
||||
|
@ -88,20 +88,20 @@ var target = new
|
|||
return Verify(target)
|
||||
.DontScrubDateTimes();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1706-L1716' 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#L1706-L1716' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimesFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: DontScrubDateTimesGlobal -->
|
||||
<a id='snippet-dontscrubdatetimesglobal'></a>
|
||||
<a id='snippet-DontScrubDateTimesGlobal'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void ModuleInitializer() =>
|
||||
VerifierSettings.DontScrubDateTimes();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1774-L1780' 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#L1774-L1780' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubDateTimesGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -113,7 +113,7 @@ If many calls are made to the the current date/time in quick succession, the dat
|
|||
### Instance
|
||||
|
||||
<!-- snippet: DisableDateCounting -->
|
||||
<a id='snippet-disabledatecounting'></a>
|
||||
<a id='snippet-DisableDateCounting'></a>
|
||||
```cs
|
||||
var target = new
|
||||
{
|
||||
|
@ -125,14 +125,14 @@ settings.DisableDateCounting();
|
|||
|
||||
return Verify(target, settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1735-L1747' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecounting' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1735-L1747' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCounting' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fluent
|
||||
|
||||
<!-- snippet: DisableDateCountingFluent -->
|
||||
<a id='snippet-disabledatecountingfluent'></a>
|
||||
<a id='snippet-DisableDateCountingFluent'></a>
|
||||
```cs
|
||||
var target = new
|
||||
{
|
||||
|
@ -142,20 +142,20 @@ var target = new
|
|||
return Verify(target)
|
||||
.DisableDateCounting();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1753-L1763' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecountingfluent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1753-L1763' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCountingFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: DisableDateCountingGlobal -->
|
||||
<a id='snippet-disabledatecountingglobal'></a>
|
||||
<a id='snippet-DisableDateCountingGlobal'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void ModuleInitializer() =>
|
||||
VerifierSettings.DisableDateCounting();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1722-L1728' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecountingglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1722-L1728' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableDateCountingGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -164,7 +164,7 @@ public static void ModuleInitializer() =>
|
|||
`AddExtraDatetimeFormat` allows specifying custom date formats to be scrubbed.
|
||||
|
||||
<!-- snippet: AddExtraDatetimeFormat -->
|
||||
<a id='snippet-addextradatetimeformat'></a>
|
||||
<a id='snippet-AddExtraDatetimeFormat'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void UseAddExtraDatetimeFormat() =>
|
||||
|
@ -178,7 +178,7 @@ public Task WithExtraDatetimeFormat() =>
|
|||
date = "2022-11-08"
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L146-L160' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextradatetimeformat' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L146-L160' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddExtraDatetimeFormat' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -190,7 +190,7 @@ Strings containing inline dates can also be scrubbed. There a equivalent APIs fo
|
|||
### Instance
|
||||
|
||||
<!-- snippet: ScrubInlineDateTimesInstance -->
|
||||
<a id='snippet-scrubinlinedatetimesinstance'></a>
|
||||
<a id='snippet-ScrubInlineDateTimesInstance'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubInlineDateTimesInstance()
|
||||
|
@ -202,28 +202,28 @@ public Task ScrubInlineDateTimesInstance()
|
|||
settings);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1658-L1670' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesinstance' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1658-L1670' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fluent
|
||||
|
||||
<!-- snippet: ScrubInlineDateTimesFluent -->
|
||||
<a id='snippet-scrubinlinedatetimesfluent'></a>
|
||||
<a id='snippet-ScrubInlineDateTimesFluent'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubInlineDateTimesFluent() =>
|
||||
Verify("content 2020-10-20 content")
|
||||
.ScrubInlineDateTimes("yyyy-MM-dd");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1649-L1656' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesfluent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1649-L1656' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: ScrubInlineDateTimesGlobal -->
|
||||
<a id='snippet-scrubinlinedatetimesglobal'></a>
|
||||
<a id='snippet-ScrubInlineDateTimesGlobal'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -232,7 +232,7 @@ public static class ModuleInitializer
|
|||
VerifierSettings.ScrubInlineDateTimes("yyyy-MM-dd");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1637-L1646' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1637-L1646' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineDateTimesGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -244,7 +244,7 @@ Specific date or times can be named. When any of those values are found, they wi
|
|||
### Instance
|
||||
|
||||
<!-- snippet: NamedDatesAndTimesInstance -->
|
||||
<a id='snippet-nameddatesandtimesinstance'></a>
|
||||
<a id='snippet-NamedDatesAndTimesInstance'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.AddNamedDate(new(2020, 10, 11), "instanceNamedDate");
|
||||
|
@ -253,14 +253,14 @@ settings.AddNamedDateTime(new(2030, 1, 2), "instanceNamedDateTime");
|
|||
settings.AddNamedDateTimeOffset(new DateTime(2030, 1, 2), "instanceNamedTimeOffset");
|
||||
await Verify(target, settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1238-L1247' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesinstance' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1238-L1247' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Instance
|
||||
|
||||
<!-- snippet: NamedDatesAndTimesFluent -->
|
||||
<a id='snippet-nameddatesandtimesfluent'></a>
|
||||
<a id='snippet-NamedDatesAndTimesFluent'></a>
|
||||
```cs
|
||||
await Verify(target)
|
||||
.AddNamedDate(new(2020, 10, 11), "instanceNamedDate")
|
||||
|
@ -268,14 +268,14 @@ await Verify(target)
|
|||
.AddNamedDateTime(new(2030, 1, 2), "instanceNamedDateTime")
|
||||
.AddNamedDateTimeOffset(new DateTime(2030, 1, 2), "instanceNamedTimeOffset");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1195-L1203' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesfluent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1195-L1203' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: NamedDatesAndTimesGlobal -->
|
||||
<a id='snippet-nameddatesandtimesglobal'></a>
|
||||
<a id='snippet-NamedDatesAndTimesGlobal'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void NamedDatesAndTimesGlobal()
|
||||
|
@ -286,5 +286,5 @@ public static void NamedDatesAndTimesGlobal()
|
|||
VerifierSettings.AddNamedDateTimeOffset(new(new(2030, 1, 1)), "namedDateTimeOffset");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1150-L1161' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1150-L1161' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedDatesAndTimesGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
|
|
@ -15,7 +15,7 @@ To change this file edit the source file and then run MarkdownSnippets.
|
|||
## NUnit
|
||||
|
||||
<!-- snippet: ExplicitTargetsNunit -->
|
||||
<a id='snippet-explicittargetsnunit'></a>
|
||||
<a id='snippet-ExplicitTargetsNunit'></a>
|
||||
```cs
|
||||
[Test]
|
||||
public Task WithTargets() =>
|
||||
|
@ -32,14 +32,14 @@ public Task WithTargets() =>
|
|||
name: "targetName")
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Tests.cs#L43-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-explicittargetsnunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Tests.cs#L43-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExplicitTargetsNunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## Xunit
|
||||
|
||||
<!-- snippet: ExplicitTargetsXunit -->
|
||||
<a id='snippet-explicittargetsxunit'></a>
|
||||
<a id='snippet-ExplicitTargetsXunit'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task WithTargets() =>
|
||||
|
@ -56,14 +56,14 @@ public Task WithTargets() =>
|
|||
name: "targetName")
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L43-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-explicittargetsxunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L43-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExplicitTargetsXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## Fixie
|
||||
|
||||
<!-- snippet: ExplicitTargetsFixie -->
|
||||
<a id='snippet-explicittargetsfixie'></a>
|
||||
<a id='snippet-ExplicitTargetsFixie'></a>
|
||||
```cs
|
||||
public Task WithTargets() =>
|
||||
Verify(
|
||||
|
@ -79,14 +79,14 @@ public Task WithTargets() =>
|
|||
name: "targetName")
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Tests.cs#L32-L48' title='Snippet source file'>snippet source</a> | <a href='#snippet-explicittargetsfixie' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Tests.cs#L32-L48' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExplicitTargetsFixie' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## MsTest
|
||||
|
||||
<!-- snippet: ExplicitTargetsMsTest -->
|
||||
<a id='snippet-explicittargetsmstest'></a>
|
||||
<a id='snippet-ExplicitTargetsMsTest'></a>
|
||||
```cs
|
||||
[TestMethod]
|
||||
public Task WithTargets() =>
|
||||
|
@ -103,7 +103,7 @@ public Task WithTargets() =>
|
|||
name: "targetName")
|
||||
]);
|
||||
```
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Tests.cs#L42-L59' title='Snippet source file'>snippet source</a> | <a href='#snippet-explicittargetsmstest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Tests.cs#L42-L59' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExplicitTargetsMsTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -21,11 +21,11 @@ VerifierSettings.AddExtraSettings(fun settings -> settings.AddFSharpConverters()
|
|||
By default [DefaultValueHandling is Ignore](/docs/serializer-settings.md#default-settings). Since F# `Option.None` is treated as null, it will be ignored by default. To include `Option.None` use `VerifierSettings.AddExtraSettings` at module startup:
|
||||
|
||||
<!-- snippet: NullValueHandling -->
|
||||
<a id='snippet-nullvaluehandling'></a>
|
||||
<a id='snippet-NullValueHandling'></a>
|
||||
```fs
|
||||
VerifierSettings.AddExtraSettings(fun settings -> settings.NullValueHandling <- NullValueHandling.Include)
|
||||
```
|
||||
<sup><a href='/src/FSharpTests/Tests.fs#L8-L10' title='Snippet source file'>snippet source</a> | <a href='#snippet-nullvaluehandling' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/FSharpTests/Tests.fs#L8-L10' title='Snippet source file'>snippet source</a> | <a href='#snippet-NullValueHandling' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -34,13 +34,13 @@ VerifierSettings.AddExtraSettings(fun settings -> settings.NullValueHandling <-
|
|||
F# does not respect implicit operator conversion. `SettingsTask` uses implicit operator conversion to provide a fluent api in combination with an instance that can be awaited. As such `SettingsTask.ToTask()` needs to be awaited when used inside F#.
|
||||
|
||||
<!-- snippet: FsTest -->
|
||||
<a id='snippet-fstest'></a>
|
||||
<a id='snippet-FsTest'></a>
|
||||
```fs
|
||||
[<Fact>]
|
||||
let MyTest () =
|
||||
Verifier.Verify(15).ToTask() |> Async.AwaitTask
|
||||
```
|
||||
<sup><a href='/src/FSharpTests/Tests.fs#L12-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-fstest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/FSharpTests/Tests.fs#L12-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-FsTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
|
|
@ -50,36 +50,36 @@ To disable this behavior use:
|
|||
### Instance
|
||||
|
||||
<!-- snippet: DontScrubGuids -->
|
||||
<a id='snippet-dontscrubguids'></a>
|
||||
<a id='snippet-DontScrubGuids'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.DontScrubGuids();
|
||||
await Verify(target, settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L716-L722' 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#L716-L722' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubGuids' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fluent
|
||||
|
||||
<!-- snippet: DontScrubGuidsFluent -->
|
||||
<a id='snippet-dontscrubguidsfluent'></a>
|
||||
<a id='snippet-DontScrubGuidsFluent'></a>
|
||||
```cs
|
||||
await Verify(target)
|
||||
.DontScrubGuids();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L730-L735' 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#L730-L735' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubGuidsFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: DontScrubGuidsGlobal -->
|
||||
<a id='snippet-dontscrubguidsglobal'></a>
|
||||
<a id='snippet-DontScrubGuidsGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.DontScrubGuids();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1573-L1577' 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#L1573-L1577' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontScrubGuidsGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -91,7 +91,7 @@ Strings containing inline Guids can also be scrubbed. To enable this behavior, u
|
|||
### Instance
|
||||
|
||||
<!-- snippet: ScrubInlineGuidsInstance -->
|
||||
<a id='snippet-scrubinlineguidsinstance'></a>
|
||||
<a id='snippet-ScrubInlineGuidsInstance'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubInlineGuidsInstance()
|
||||
|
@ -103,28 +103,28 @@ public Task ScrubInlineGuidsInstance()
|
|||
settings);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1622-L1634' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguidsinstance' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1622-L1634' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fluent
|
||||
|
||||
<!-- snippet: ScrubInlineGuidsFluent -->
|
||||
<a id='snippet-scrubinlineguidsfluent'></a>
|
||||
<a id='snippet-ScrubInlineGuidsFluent'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubInlineGuidsFluent() =>
|
||||
Verify("content 651ad409-fc30-4b12-a47e-616d3f953e4c content")
|
||||
.ScrubInlineGuids();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1613-L1620' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguidsfluent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1613-L1620' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: ScrubInlineGuidsGlobal -->
|
||||
<a id='snippet-scrubinlineguidsglobal'></a>
|
||||
<a id='snippet-ScrubInlineGuidsGlobal'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -133,7 +133,7 @@ public static class ModuleInitializer
|
|||
VerifierSettings.ScrubInlineGuids();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1601-L1610' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlineguidsglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1601-L1610' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubInlineGuidsGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -145,7 +145,7 @@ Specific Guids can be named. When any of those Guids are found, it will be repla
|
|||
### Instance
|
||||
|
||||
<!-- snippet: NamedGuidInstance -->
|
||||
<a id='snippet-namedguidinstance'></a>
|
||||
<a id='snippet-NamedGuidInstance'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task NamedGuidInstance()
|
||||
|
@ -160,14 +160,14 @@ public Task NamedGuidInstance()
|
|||
settings);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/GuidScrubberTests.cs#L64-L79' title='Snippet source file'>snippet source</a> | <a href='#snippet-namedguidinstance' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/GuidScrubberTests.cs#L64-L79' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedGuidInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Instance
|
||||
|
||||
<!-- snippet: NamedGuidFluent -->
|
||||
<a id='snippet-namedguidfluent'></a>
|
||||
<a id='snippet-NamedGuidFluent'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task NamedGuidFluent() =>
|
||||
|
@ -178,18 +178,18 @@ public Task NamedGuidFluent() =>
|
|||
})
|
||||
.AddNamedGuid(new("c8eeaf99-d5c4-4341-8543-4597c3fd40d9"), "instanceNamed");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/GuidScrubberTests.cs#L81-L92' title='Snippet source file'>snippet source</a> | <a href='#snippet-namedguidfluent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/GuidScrubberTests.cs#L81-L92' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedGuidFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: NamedGuidGlobal -->
|
||||
<a id='snippet-namedguidglobal'></a>
|
||||
<a id='snippet-NamedGuidGlobal'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void Init() =>
|
||||
VerifierSettings.AddNamedGuid(new("c8eeaf99-d5c4-4341-8543-4597c3fd40c9"), "guidName");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/GuidScrubberTests.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-namedguidglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/GuidScrubberTests.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-NamedGuidGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -80,5 +80,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -67,5 +67,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -89,5 +89,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -76,5 +76,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -76,5 +76,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -76,5 +76,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -76,5 +76,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -76,5 +76,5 @@ Tools supported by Linux:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -88,5 +88,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -86,5 +86,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -88,5 +88,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -88,5 +88,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -88,5 +88,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -73,5 +73,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -73,5 +73,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -73,5 +73,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -73,5 +73,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -73,5 +73,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -97,5 +97,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -95,5 +95,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -97,5 +97,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -97,5 +97,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -97,5 +97,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -82,5 +82,5 @@ Tools supported by MacOS:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -104,5 +104,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -115,5 +115,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -113,5 +113,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -115,5 +115,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -115,5 +115,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -115,5 +115,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -100,5 +100,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -100,5 +100,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -100,5 +100,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -100,5 +100,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -100,5 +100,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -123,5 +123,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -121,5 +121,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -123,5 +123,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -123,5 +123,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -123,5 +123,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -108,5 +108,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -108,5 +108,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -108,5 +108,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -108,5 +108,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -108,5 +108,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -104,5 +104,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -106,5 +106,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -91,5 +91,5 @@ Tools supported by Windows:
|
|||
|
||||
## Getting .received in output on AppVeyor
|
||||
|
||||
include: build-server-AppVeyor
|
||||
include: build-server-appveyor
|
||||
|
||||
|
|
|
@ -14,22 +14,22 @@ Due to the use of [ITuple](https://docs.microsoft.com/en-us/dotnet/api/system.ru
|
|||
Given a method that returns a named tuple:
|
||||
|
||||
<!-- snippet: MethodWithNamedTuple -->
|
||||
<a id='snippet-methodwithnamedtuple'></a>
|
||||
<a id='snippet-MethodWithNamedTuple'></a>
|
||||
```cs
|
||||
static (bool Member1, string Member2, string Member3) MethodWithNamedTuple() =>
|
||||
(true, "A", "B");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1974-L1979' 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#L1974-L1979' title='Snippet source file'>snippet source</a> | <a href='#snippet-MethodWithNamedTuple' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Can be verified:
|
||||
|
||||
<!-- snippet: VerifyTuple -->
|
||||
<a id='snippet-verifytuple'></a>
|
||||
<a id='snippet-VerifyTuple'></a>
|
||||
```cs
|
||||
await VerifyTuple(() => MethodWithNamedTuple());
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1967-L1971' 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#L1967-L1971' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyTuple' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Resulting in:
|
||||
|
|
|
@ -21,22 +21,22 @@ The format is
|
|||
The directory that contains the test. A custom directory can be used via `UseDirectory`:
|
||||
|
||||
<!-- snippet: UseDirectory -->
|
||||
<a id='snippet-usedirectory'></a>
|
||||
<a id='snippet-UseDirectory'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.UseDirectory("CustomDirectory");
|
||||
await Verify("valueUseDirectory", settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L199-L205' 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#L199-L205' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseDirectory' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: UseDirectoryFluent -->
|
||||
<a id='snippet-usedirectoryfluent'></a>
|
||||
<a id='snippet-UseDirectoryFluent'></a>
|
||||
```cs
|
||||
await Verify("valueUseDirectoryFluent")
|
||||
.UseDirectory("CustomDirectory");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L211-L216' 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#L211-L216' 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`.
|
||||
|
@ -49,22 +49,22 @@ The path provided can be absolute or relative to the directory that contains the
|
|||
The class name that contains the test. A custom test name can be used via `UseTypeName`:
|
||||
|
||||
<!-- snippet: UseTypeName -->
|
||||
<a id='snippet-usetypename'></a>
|
||||
<a id='snippet-UseTypeName'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.UseTypeName("CustomTypeName");
|
||||
await Verify("valueUseTypeName", settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L310-L316' 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#L310-L316' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseTypeName' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: UseTypeNameFluent -->
|
||||
<a id='snippet-usetypenamefluent'></a>
|
||||
<a id='snippet-UseTypeNameFluent'></a>
|
||||
```cs
|
||||
await Verify("valueUseTypeNameFluent")
|
||||
.UseTypeName("CustomTypeName");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L322-L327' 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#L322-L327' 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`.
|
||||
|
@ -75,24 +75,24 @@ Will result in `CustomTypeName.MethodName.verified.txt`.
|
|||
The test method name. A custom test name can be used via `UseMethodName`:
|
||||
|
||||
<!-- snippet: UseMethodName -->
|
||||
<a id='snippet-usemethodname'></a>
|
||||
<a id='snippet-UseMethodName'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.UseMethodName("CustomMethodName");
|
||||
await Verify("valueUseMethodName", settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L333-L339' 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#L333-L339' 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`.
|
||||
|
||||
<!-- snippet: UseMethodNameFluent -->
|
||||
<a id='snippet-usemethodnamefluent'></a>
|
||||
<a id='snippet-UseMethodNameFluent'></a>
|
||||
```cs
|
||||
await Verify("valueUseMethodNameFluent")
|
||||
.UseMethodName("CustomMethodNameFluent");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L345-L350' 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#L345-L350' 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`.
|
||||
|
@ -103,7 +103,7 @@ Will result in `TestClass.CustomMethodNameFluent.verified.txt`.
|
|||
`UseMethodName` can also be used to allow multiple calls to Verify in the same method:
|
||||
|
||||
<!-- snippet: MultipleCalls -->
|
||||
<a id='snippet-multiplecalls'></a>
|
||||
<a id='snippet-MultipleCalls'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task MultipleCalls() =>
|
||||
|
@ -113,7 +113,7 @@ public Task MultipleCalls() =>
|
|||
Verify("Value1MultipleCalls")
|
||||
.UseMethodName("MultipleCalls_2"));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L51-L61' 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#L51-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-MultipleCalls' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -122,24 +122,24 @@ public Task MultipleCalls() =>
|
|||
To fully control the `{TestClassName}.{TestMethodName}_{Parameters}` parts of the file use `UseFileName`:
|
||||
|
||||
<!-- snippet: UseFileName -->
|
||||
<a id='snippet-usefilename'></a>
|
||||
<a id='snippet-UseFileName'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.UseFileName("CustomFileName");
|
||||
await Verify("valueUseFileName", settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L167-L173' 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#L167-L173' 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`.
|
||||
|
||||
<!-- snippet: UseFileNameFluent -->
|
||||
<a id='snippet-usefilenamefluent'></a>
|
||||
<a id='snippet-UseFileNameFluent'></a>
|
||||
```cs
|
||||
await Verify("valueUseFileNameFluent")
|
||||
.UseFileName("CustomFileNameFluent");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L188-L193' 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#L188-L193' 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`.
|
||||
|
@ -164,7 +164,7 @@ See [Parameterised Tests](parameterised.md).
|
|||
### NUnit
|
||||
|
||||
<!-- snippet: UniqueForSampleNUnit -->
|
||||
<a id='snippet-uniqueforsamplenunit'></a>
|
||||
<a id='snippet-UniqueForSampleNUnit'></a>
|
||||
```cs
|
||||
[TestFixture]
|
||||
public class UniqueForSample
|
||||
|
@ -235,14 +235,14 @@ public class UniqueForSample
|
|||
.UniqueForOSPlatform();
|
||||
}
|
||||
```
|
||||
<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>
|
||||
<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 -->
|
||||
|
||||
|
||||
### XUnit
|
||||
|
||||
<!-- snippet: UniqueForSampleXunit -->
|
||||
<a id='snippet-uniqueforsamplexunit'></a>
|
||||
<a id='snippet-UniqueForSampleXunit'></a>
|
||||
```cs
|
||||
public class UniqueForSample
|
||||
{
|
||||
|
@ -307,14 +307,14 @@ public class UniqueForSample
|
|||
.UniqueForOSPlatform();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L1-L66' 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-L66' title='Snippet source file'>snippet source</a> | <a href='#snippet-UniqueForSampleXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fixie
|
||||
|
||||
<!-- snippet: UniqueForSampleFixie -->
|
||||
<a id='snippet-uniqueforsamplefixie'></a>
|
||||
<a id='snippet-UniqueForSampleFixie'></a>
|
||||
```cs
|
||||
public class UniqueForSample
|
||||
{
|
||||
|
@ -374,14 +374,14 @@ public class UniqueForSample
|
|||
.UniqueForOSPlatform();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Snippets/UniqueForSample.cs#L1-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplefixie' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Snippets/UniqueForSample.cs#L1-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-UniqueForSampleFixie' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### MSTest
|
||||
|
||||
<!-- snippet: UniqueForSampleMSTest -->
|
||||
<a id='snippet-uniqueforsamplemstest'></a>
|
||||
<a id='snippet-UniqueForSampleMSTest'></a>
|
||||
```cs
|
||||
[TestClass]
|
||||
public class UniqueForSample :
|
||||
|
@ -453,14 +453,14 @@ public class UniqueForSample :
|
|||
.UniqueForOSPlatform();
|
||||
}
|
||||
```
|
||||
<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>
|
||||
<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 -->
|
||||
|
||||
|
||||
### Expecto
|
||||
|
||||
<!-- snippet: UniqueForSampleExpecto -->
|
||||
<a id='snippet-uniqueforsampleexpecto'></a>
|
||||
<a id='snippet-UniqueForSampleExpecto'></a>
|
||||
```fs
|
||||
[<Tests>]
|
||||
let uniqueTests =
|
||||
|
@ -470,7 +470,7 @@ let uniqueTests =
|
|||
do! Verifier.Verify("unique", "value", settings)
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Expecto.FSharpTests/Tests.fs#L16-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsampleexpecto' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Expecto.FSharpTests/Tests.fs#L16-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-UniqueForSampleExpecto' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -506,7 +506,7 @@ It can be overridden at two levels:
|
|||
Usage:
|
||||
|
||||
<!-- snippet: XunitExtensionSample -->
|
||||
<a id='snippet-xunitextensionsample'></a>
|
||||
<a id='snippet-XunitExtensionSample'></a>
|
||||
```cs
|
||||
public class ExtensionSample
|
||||
{
|
||||
|
@ -535,7 +535,7 @@ public class ExtensionSample
|
|||
extension: "xml");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.cs#L1-L30' 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-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-XunitExtensionSample' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result in:
|
||||
|
@ -558,12 +558,12 @@ Result in:
|
|||
To access the current Namer `Runtime` or `RuntimeAndVersion` strings use:
|
||||
|
||||
<!-- snippet: AccessNamerRuntimeAndVersion -->
|
||||
<a id='snippet-accessnamerruntimeandversion'></a>
|
||||
<a id='snippet-AccessNamerRuntimeAndVersion'></a>
|
||||
```cs
|
||||
Debug.WriteLine(Namer.Runtime);
|
||||
Debug.WriteLine(Namer.RuntimeAndVersion);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L356-L361' 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#L356-L361' title='Snippet source file'>snippet source</a> | <a href='#snippet-AccessNamerRuntimeAndVersion' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -586,7 +586,7 @@ For example to place all `.verified.` files in a `{ProjectDirectory}\Snapshots`
|
|||
### Xunit
|
||||
|
||||
<!-- snippet: DerivePathInfoXUnit -->
|
||||
<a id='snippet-derivepathinfoxunit'></a>
|
||||
<a id='snippet-DerivePathInfoXUnit'></a>
|
||||
```cs
|
||||
Verifier.DerivePathInfo(
|
||||
(sourceFile, projectDirectory, type, method) => new(
|
||||
|
@ -594,14 +594,14 @@ Verifier.DerivePathInfo(
|
|||
typeName: type.Name,
|
||||
methodName: method.Name));
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L8-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-derivepathinfoxunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L8-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-DerivePathInfoXUnit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### NUnit
|
||||
|
||||
<!-- snippet: DerivePathInfoNunit -->
|
||||
<a id='snippet-derivepathinfonunit'></a>
|
||||
<a id='snippet-DerivePathInfoNunit'></a>
|
||||
```cs
|
||||
Verifier.DerivePathInfo(
|
||||
(sourceFile, projectDirectory, type, method) => new(
|
||||
|
@ -609,14 +609,14 @@ Verifier.DerivePathInfo(
|
|||
typeName: type.Name,
|
||||
methodName: method.Name));
|
||||
```
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Tests.cs#L8-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-derivepathinfonunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Tests.cs#L8-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-DerivePathInfoNunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### MSTest
|
||||
|
||||
<!-- snippet: DerivePathInfoMSTest -->
|
||||
<a id='snippet-derivepathinfomstest'></a>
|
||||
<a id='snippet-DerivePathInfoMSTest'></a>
|
||||
```cs
|
||||
DerivePathInfo(
|
||||
(sourceFile, projectDirectory, type, method) => new(
|
||||
|
@ -624,14 +624,14 @@ DerivePathInfo(
|
|||
typeName: type.Name,
|
||||
methodName: method.Name));
|
||||
```
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Tests.cs#L10-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-derivepathinfomstest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Tests.cs#L10-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-DerivePathInfoMSTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Expecto
|
||||
|
||||
<!-- snippet: DerivePathInfoExpecto -->
|
||||
<a id='snippet-derivepathinfoexpecto'></a>
|
||||
<a id='snippet-DerivePathInfoExpecto'></a>
|
||||
```cs
|
||||
Verifier.DerivePathInfo(
|
||||
(sourceFile, projectDirectory, type, method) => new(
|
||||
|
@ -639,7 +639,7 @@ Verifier.DerivePathInfo(
|
|||
typeName: type,
|
||||
methodName: method));
|
||||
```
|
||||
<sup><a href='/src/Verify.Expecto.Tests/Tests.cs#L8-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-derivepathinfoexpecto' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Expecto.Tests/Tests.cs#L8-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-DerivePathInfoExpecto' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -651,7 +651,7 @@ A `DerivePathInfo` convention can be shipped as a NuGet, for example [Spectre.Ve
|
|||
### Default DerivePathInfo
|
||||
|
||||
<!-- snippet: defaultDerivePathInfo -->
|
||||
<a id='snippet-defaultderivepathinfo'></a>
|
||||
<a id='snippet-defaultDerivePathInfo'></a>
|
||||
```cs
|
||||
public static PathInfo DeriveDefault(
|
||||
string sourceFile,
|
||||
|
@ -663,13 +663,13 @@ public static PathInfo DeriveDefault(
|
|||
typeName: type.NameWithParent(),
|
||||
methodName: method.Name);
|
||||
```
|
||||
<sup><a href='/src/Verify/DerivePaths/PathInfo.cs#L23-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-defaultderivepathinfo' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify/DerivePaths/PathInfo.cs#L23-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-defaultDerivePathInfo' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Where `NameWithParent` is
|
||||
|
||||
<!-- snippet: NameWithParent -->
|
||||
<a id='snippet-namewithparent'></a>
|
||||
<a id='snippet-NameWithParent'></a>
|
||||
```cs
|
||||
public static string NameWithParent(this Type type)
|
||||
{
|
||||
|
@ -681,7 +681,7 @@ public static string NameWithParent(this Type type)
|
|||
return type.Name;
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify/Extensions.cs#L100-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-namewithparent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify/Extensions.cs#L100-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-NameWithParent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -716,13 +716,13 @@ The file format is:
|
|||
```
|
||||
|
||||
<!-- snippet: UseUniqueDirectory -->
|
||||
<a id='snippet-useuniquedirectory'></a>
|
||||
<a id='snippet-UseUniqueDirectory'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.UseUniqueDirectory();
|
||||
await Verify("TheValue", settings);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L222-L228' title='Snippet source file'>snippet source</a> | <a href='#snippet-useuniquedirectory' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L222-L228' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseUniqueDirectory' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -747,7 +747,7 @@ For verified files:
|
|||
```
|
||||
|
||||
<!-- snippet: UseSplitModeForUniqueDirectory -->
|
||||
<a id='snippet-usesplitmodeforuniquedirectory'></a>
|
||||
<a id='snippet-UseSplitModeForUniqueDirectory'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -756,7 +756,7 @@ public static class ModuleInitializer
|
|||
VerifierSettings.UseSplitModeForUniqueDirectory();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/ModuleInitDocs/UseSplitModeForUniqueDirectory.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-usesplitmodeforuniquedirectory' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/ModuleInitDocs/UseSplitModeForUniqueDirectory.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseSplitModeForUniqueDirectory' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
**Also exclude `*.received/` from source control.**
|
||||
|
|
|
@ -32,7 +32,7 @@ Characters that cannot be used for a file name are replaced with a dash (`-`).
|
|||
`UseParameters`() is used to control what parameters are used when naming files. The usual usage is to pass though all parameters (in the same order) that the test method accepts:
|
||||
|
||||
<!-- snippet: UseParameters -->
|
||||
<a id='snippet-useparameters'></a>
|
||||
<a id='snippet-UseParameters'></a>
|
||||
```cs
|
||||
[Theory]
|
||||
[InlineData("Value1")]
|
||||
|
@ -44,13 +44,13 @@ public Task UseParametersUsage(string arg)
|
|||
.UseParameters(arg);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L50-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-useparameters' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L50-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParameters' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
If not all parameters are required, a subset can be passed in. In this scenario, the parameters passed in will match with the method parameter names from the start. For example the following will result in a file named `ParametersSample.UseParametersSubSet_arg1=Value1_arg2=Value2.verified.txt`
|
||||
|
||||
<!-- snippet: UseParametersSubSet -->
|
||||
<a id='snippet-useparameterssubset'></a>
|
||||
<a id='snippet-UseParametersSubSet'></a>
|
||||
```cs
|
||||
[Theory]
|
||||
[InlineData("Value1", "Value2", "Value3")]
|
||||
|
@ -61,7 +61,7 @@ public Task UseParametersSubSet(string arg1, string arg2, string arg3)
|
|||
.UseParameters(arg1, arg2);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L64-L75' title='Snippet source file'>snippet source</a> | <a href='#snippet-useparameterssubset' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L64-L75' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersSubSet' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.
|
||||
|
@ -73,14 +73,14 @@ If the number of parameters passed to `UseParameters()` is greater than the numb
|
|||
### TestCase
|
||||
|
||||
<!-- snippet: NUnitTestCase -->
|
||||
<a id='snippet-nunittestcase'></a>
|
||||
<a id='snippet-NUnitTestCase'></a>
|
||||
```cs
|
||||
[TestCase("Value1")]
|
||||
[TestCase("Value2")]
|
||||
public Task TestCaseUsage(string arg) =>
|
||||
Verify(arg);
|
||||
```
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ParametersSample.cs#L16-L23' 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#L16-L23' title='Snippet source file'>snippet source</a> | <a href='#snippet-NUnitTestCase' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -130,7 +130,7 @@ Produces `TestFixtureSourceUsage(Value1,1).Test.verified.txt` and `TestFixtureSo
|
|||
### InlineData
|
||||
|
||||
<!-- snippet: xunitInlineData -->
|
||||
<a id='snippet-xunitinlinedata'></a>
|
||||
<a id='snippet-xunitInlineData'></a>
|
||||
```cs
|
||||
[Theory]
|
||||
[InlineData("Value1")]
|
||||
|
@ -149,14 +149,14 @@ public Task InlineDataUsageFluent(string arg) =>
|
|||
Verify(arg)
|
||||
.UseParameters(arg);
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L29-L48' 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#L29-L48' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitInlineData' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### MemberData
|
||||
|
||||
<!-- snippet: xunitMemberData -->
|
||||
<a id='snippet-xunitmemberdata'></a>
|
||||
<a id='snippet-xunitMemberData'></a>
|
||||
```cs
|
||||
[Theory]
|
||||
[MemberData(nameof(GetData))]
|
||||
|
@ -185,7 +185,7 @@ public static IEnumerable<object[]> GetData()
|
|||
];
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L77-L106' 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#L77-L106' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitMemberData' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -194,7 +194,7 @@ public static IEnumerable<object[]> GetData()
|
|||
xUnit only exposes parameter information for certain types. For unknown types the information cannot be retrieved from the xUnit context, and instead the text for the parameter value needs to be explicitly specified. This is done by calling `NameForParameter()`.
|
||||
|
||||
<!-- snippet: xunitComplexMemberData -->
|
||||
<a id='snippet-xunitcomplexmemberdata'></a>
|
||||
<a id='snippet-xunitComplexMemberData'></a>
|
||||
```cs
|
||||
public class ComplexParametersSample
|
||||
{
|
||||
|
@ -309,7 +309,7 @@ public class ComplexParametersSample
|
|||
}
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L1-L116' 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-L116' 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.
|
||||
|
@ -375,14 +375,14 @@ public class TestProject :
|
|||
Resulting usage:
|
||||
|
||||
<!-- snippet: FixieTestCase -->
|
||||
<a id='snippet-fixietestcase'></a>
|
||||
<a id='snippet-FixieTestCase'></a>
|
||||
```cs
|
||||
[TestCase("Value1")]
|
||||
[TestCase("Value2")]
|
||||
public Task TestCaseUsage(string arg) =>
|
||||
Verify(arg);
|
||||
```
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Snippets/ParametersSample.cs#L18-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-fixietestcase' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Snippets/ParametersSample.cs#L18-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-FixieTestCase' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -392,7 +392,7 @@ public Task TestCaseUsage(string arg) =>
|
|||
### DataRow
|
||||
|
||||
<!-- snippet: MSTestDataRow -->
|
||||
<a id='snippet-mstestdatarow'></a>
|
||||
<a id='snippet-MSTestDataRow'></a>
|
||||
```cs
|
||||
[TestClass]
|
||||
public class ParametersSample :
|
||||
|
@ -416,7 +416,7 @@ public class ParametersSample :
|
|||
.UseParameters(arg);
|
||||
}
|
||||
```
|
||||
<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>
|
||||
<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 -->
|
||||
|
||||
|
||||
|
@ -429,7 +429,7 @@ public class ParametersSample :
|
|||
```
|
||||
|
||||
<!-- snippet: UseTextForParameters -->
|
||||
<a id='snippet-usetextforparameters'></a>
|
||||
<a id='snippet-UseTextForParameters'></a>
|
||||
```cs
|
||||
[Theory]
|
||||
[InlineData("Value1")]
|
||||
|
@ -448,7 +448,7 @@ public Task UseTextForParametersFluent(string arg) =>
|
|||
Verify(arg + "UseTextForParametersFluent")
|
||||
.UseTextForParameters(arg);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L408-L427' 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#L408-L427' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseTextForParameters' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -464,7 +464,7 @@ Results in:
|
|||
By default, Verify expects every parameterised case to have a unique [file name](/docs/naming.md) with the parameters appended to the file name. This behavior can be overridden by using `IgnoreParametersForVerified()`. In this case, the verified file name does not contain the parameter values, meaning it is the same for each testcase.
|
||||
|
||||
<!-- snippet: IgnoreParametersForVerified -->
|
||||
<a id='snippet-ignoreparametersforverified'></a>
|
||||
<a id='snippet-IgnoreParametersForVerified'></a>
|
||||
```cs
|
||||
[Theory]
|
||||
[InlineData("One")]
|
||||
|
@ -483,7 +483,7 @@ public Task IgnoreParametersForVerifiedFluent(string arg) =>
|
|||
Verify("valueIgnoreParametersForVerifiedFluent")
|
||||
.IgnoreParametersForVerified(arg);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L480-L499' 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#L480-L499' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerified' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -513,7 +513,7 @@ Hashing parameter is achieved by using `UseParameters` in combination with `Hash
|
|||
### MSTest
|
||||
|
||||
<!-- snippet: UseParametersHashMsTest -->
|
||||
<a id='snippet-useparametershashmstest'></a>
|
||||
<a id='snippet-UseParametersHashMsTest'></a>
|
||||
```cs
|
||||
[TestClass]
|
||||
public class ParametersHashSample :
|
||||
|
@ -556,14 +556,14 @@ public class ParametersHashSample :
|
|||
.HashParameters();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersHashSample.cs#L3-L46' title='Snippet source file'>snippet source</a> | <a href='#snippet-useparametershashmstest' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersHashSample.cs#L3-L46' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersHashMsTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### NUnit
|
||||
|
||||
<!-- snippet: UseParametersHashNunit -->
|
||||
<a id='snippet-useparametershashnunit'></a>
|
||||
<a id='snippet-UseParametersHashNunit'></a>
|
||||
```cs
|
||||
[TestFixture]
|
||||
public class ParametersHashSample
|
||||
|
@ -615,7 +615,7 @@ public class ParametersHashSample
|
|||
.HashParameters();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ParametersHashSample.cs#L3-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-useparametershashnunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ParametersHashSample.cs#L3-L55' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersHashNunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Note that NUnit can derive the parameters without explicitly passing them.
|
||||
|
@ -623,8 +623,8 @@ Note that NUnit can derive the parameters without explicitly passing them.
|
|||
|
||||
### xUnit
|
||||
|
||||
<!-- snippet: UseParametersHashxUnit -->
|
||||
<a id='snippet-useparametershashxunit'></a>
|
||||
<!-- snippet: UseParametersHashXunit -->
|
||||
<a id='snippet-UseParametersHashXunit'></a>
|
||||
```cs
|
||||
public class ParametersHashSample
|
||||
{
|
||||
|
@ -665,5 +665,5 @@ public class ParametersHashSample
|
|||
.HashParameters();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersHashSample.cs#L3-L44' title='Snippet source file'>snippet source</a> | <a href='#snippet-useparametershashxunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersHashSample.cs#L3-L44' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersHashXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
|
|
@ -15,7 +15,7 @@ The main value of this feature is to simplify addition of information to a snaps
|
|||
## Usage
|
||||
|
||||
<!-- snippet: Recording -->
|
||||
<a id='snippet-recording'></a>
|
||||
<a id='snippet-Recording'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Usage()
|
||||
|
@ -25,7 +25,7 @@ public Task Usage()
|
|||
return Verify("TheValue");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L23-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-recording' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L23-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-Recording' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -49,7 +49,7 @@ If `Recording.Add()` is called before `Recording.Start` an exception will be cal
|
|||
`Recording.TryAdd()` will add an item only if `Recording.IsRecording` is true.
|
||||
|
||||
<!-- snippet: RecordingTryAdd -->
|
||||
<a id='snippet-recordingtryadd'></a>
|
||||
<a id='snippet-RecordingTryAdd'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task TryAdd()
|
||||
|
@ -61,7 +61,7 @@ public Task TryAdd()
|
|||
return Verify("TheValue");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L59-L71' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingtryadd' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L59-L71' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingTryAdd' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -70,7 +70,7 @@ public Task TryAdd()
|
|||
Recording can be scoped via a `using`:
|
||||
|
||||
<!-- snippet: RecordingScoped -->
|
||||
<a id='snippet-recordingscoped'></a>
|
||||
<a id='snippet-RecordingScoped'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task RecordingScoped()
|
||||
|
@ -85,7 +85,7 @@ public Task RecordingScoped()
|
|||
return Verify();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L73-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingscoped' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L73-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingScoped' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -106,7 +106,7 @@ Results in:
|
|||
Values are grouped by key:
|
||||
|
||||
<!-- snippet: RecordingSameKey -->
|
||||
<a id='snippet-recordingsamekey'></a>
|
||||
<a id='snippet-RecordingSameKey'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task SameKey()
|
||||
|
@ -117,7 +117,7 @@ public Task SameKey()
|
|||
return Verify("TheValue");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L272-L283' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingsamekey' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L272-L283' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingSameKey' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -144,7 +144,7 @@ To avoid grouping use [Stop](#stop).
|
|||
Recording can be grouped by an identifier.
|
||||
|
||||
<!-- snippet: RecordingIdentifier -->
|
||||
<a id='snippet-recordingidentifier'></a>
|
||||
<a id='snippet-RecordingIdentifier'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Identifier()
|
||||
|
@ -154,7 +154,7 @@ public Task Identifier()
|
|||
return Verify(Recording.Stop("identifier"));
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L90-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingidentifier' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L90-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIdentifier' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -175,7 +175,7 @@ Results in:
|
|||
## Case is ignored
|
||||
|
||||
<!-- snippet: RecordingIgnoreCase -->
|
||||
<a id='snippet-recordingignorecase'></a>
|
||||
<a id='snippet-RecordingIgnoreCase'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Case()
|
||||
|
@ -186,7 +186,7 @@ public Task Case()
|
|||
return Verify("TheValue");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L294-L305' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingignorecase' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L294-L305' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingIgnoreCase' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -209,7 +209,7 @@ Results in:
|
|||
Recording can be stopped and the resulting data can be manually verified:
|
||||
|
||||
<!-- snippet: RecordingStop -->
|
||||
<a id='snippet-recordingstop'></a>
|
||||
<a id='snippet-RecordingStop'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Stop()
|
||||
|
@ -221,7 +221,7 @@ public Task Stop()
|
|||
return Verify(appends.Where(_ => _.Name != "name1"));
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L132-L144' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingstop' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L132-L144' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStop' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -241,7 +241,7 @@ Results in:
|
|||
If Stop is called, the results are not automatically verified:
|
||||
|
||||
<!-- snippet: RecordingStopNotInResult -->
|
||||
<a id='snippet-recordingstopnotinresult'></a>
|
||||
<a id='snippet-RecordingStopNotInResult'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task StopNotInResult()
|
||||
|
@ -253,7 +253,7 @@ public Task StopNotInResult()
|
|||
return Verify("other data");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L146-L158' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingstopnotinresult' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L146-L158' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingStopNotInResult' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -272,7 +272,7 @@ other data
|
|||
The status of Recording can be checked.
|
||||
|
||||
<!-- snippet: IsRecording -->
|
||||
<a id='snippet-isrecording'></a>
|
||||
<a id='snippet-IsRecording'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public void IsRecording()
|
||||
|
@ -282,7 +282,7 @@ public void IsRecording()
|
|||
Assert.True(Recording.IsRecording());
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L102-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-isrecording' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L102-L112' title='Snippet source file'>snippet source</a> | <a href='#snippet-IsRecording' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
This can be helpful if the cost of capturing data, to add to recording, is high.
|
||||
|
@ -293,7 +293,7 @@ This can be helpful if the cost of capturing data, to add to recording, is high.
|
|||
The current recorded items can be cleared:
|
||||
|
||||
<!-- snippet: RecordingClear -->
|
||||
<a id='snippet-recordingclear'></a>
|
||||
<a id='snippet-RecordingClear'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Clear()
|
||||
|
@ -305,7 +305,7 @@ public Task Clear()
|
|||
return Verify();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L192-L204' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingclear' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L192-L204' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingClear' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
@ -326,7 +326,7 @@ Results in:
|
|||
Recording can be paused and resumed:
|
||||
|
||||
<!-- snippet: RecordingPauseResume -->
|
||||
<a id='snippet-recordingpauseresume'></a>
|
||||
<a id='snippet-RecordingPauseResume'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task PauseResume()
|
||||
|
@ -341,7 +341,7 @@ public Task PauseResume()
|
|||
return Verify();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L216-L231' title='Snippet source file'>snippet source</a> | <a href='#snippet-recordingpauseresume' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/RecordingTests.cs#L216-L231' title='Snippet source file'>snippet source</a> | <a href='#snippet-RecordingPauseResume' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Results in:
|
||||
|
|
|
@ -54,11 +54,11 @@ Allows lines to be selectively removed using a `Func`.
|
|||
For example remove lines containing `text`:
|
||||
|
||||
<!-- snippet: ScrubLines -->
|
||||
<a id='snippet-scrublines'></a>
|
||||
<a id='snippet-ScrubLines'></a>
|
||||
```cs
|
||||
verifySettings.ScrubLines(line => line.Contains("text"));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1796-L1800' 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#L1796-L1800' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLines' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -69,11 +69,11 @@ Remove all lines containing any of the defined strings.
|
|||
For example remove lines containing `text1` or `text2`
|
||||
|
||||
<!-- snippet: ScrubLinesContaining -->
|
||||
<a id='snippet-scrublinescontaining'></a>
|
||||
<a id='snippet-ScrubLinesContaining'></a>
|
||||
```cs
|
||||
verifySettings.ScrubLinesContaining("text1", "text2");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1802-L1806' 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#L1802-L1806' 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).
|
||||
|
@ -81,11 +81,11 @@ Case insensitive by default (StringComparison.OrdinalIgnoreCase).
|
|||
`StringComparison` can be overridden:
|
||||
|
||||
<!-- snippet: ScrubLinesContainingOrdinal -->
|
||||
<a id='snippet-scrublinescontainingordinal'></a>
|
||||
<a id='snippet-ScrubLinesContainingOrdinal'></a>
|
||||
```cs
|
||||
verifySettings.ScrubLinesContaining(StringComparison.Ordinal, "text1", "text2");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1808-L1812' 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#L1808-L1812' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesContainingOrdinal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -96,11 +96,11 @@ Allows lines to be selectively replaced using a `Func`.
|
|||
For example converts lines to upper case:
|
||||
|
||||
<!-- snippet: ScrubLinesWithReplace -->
|
||||
<a id='snippet-scrublineswithreplace'></a>
|
||||
<a id='snippet-ScrubLinesWithReplace'></a>
|
||||
```cs
|
||||
verifySettings.ScrubLinesWithReplace(line => line.ToUpper());
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1814-L1818' 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#L1814-L1818' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubLinesWithReplace' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -109,11 +109,11 @@ verifySettings.ScrubLinesWithReplace(line => line.ToUpper());
|
|||
Replaces `Environment.MachineName` with `TheMachineName`.
|
||||
|
||||
<!-- snippet: ScrubMachineName -->
|
||||
<a id='snippet-scrubmachinename'></a>
|
||||
<a id='snippet-ScrubMachineName'></a>
|
||||
```cs
|
||||
verifySettings.ScrubMachineName();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1820-L1824' 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#L1820-L1824' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMachineName' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -122,11 +122,11 @@ verifySettings.ScrubMachineName();
|
|||
Replaces `Environment.UserName` with `TheUserName`.
|
||||
|
||||
<!-- snippet: ScrubUserName -->
|
||||
<a id='snippet-scrubusername'></a>
|
||||
<a id='snippet-ScrubUserName'></a>
|
||||
```cs
|
||||
verifySettings.ScrubUserName();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1826-L1830' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubusername' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1826-L1830' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubUserName' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ Adds a scrubber with full control over the text via a `Func`
|
|||
### NUnit
|
||||
|
||||
<!-- snippet: ScrubbersSampleNUnit -->
|
||||
<a id='snippet-scrubberssamplenunit'></a>
|
||||
<a id='snippet-ScrubbersSampleNUnit'></a>
|
||||
```cs
|
||||
[TestFixture]
|
||||
public class ScrubbersSample
|
||||
|
@ -258,14 +258,14 @@ public class ScrubbersSample
|
|||
.ScrubEmptyLines();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubbersSample.cs#L1-L118' 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-L118' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubbersSampleNUnit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### xUnit
|
||||
|
||||
<!-- snippet: ScrubbersSampleXunit -->
|
||||
<a id='snippet-scrubberssamplexunit'></a>
|
||||
<a id='snippet-ScrubbersSampleXunit'></a>
|
||||
```cs
|
||||
public class ScrubbersSample
|
||||
{
|
||||
|
@ -393,14 +393,14 @@ public class ScrubbersSample
|
|||
.ScrubEmptyLines();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L129' 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-L129' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubbersSampleXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fixie
|
||||
|
||||
<!-- snippet: ScrubbersSampleFixie -->
|
||||
<a id='snippet-scrubberssamplefixie'></a>
|
||||
<a id='snippet-ScrubbersSampleFixie'></a>
|
||||
```cs
|
||||
public class ScrubbersSample
|
||||
{
|
||||
|
@ -510,14 +510,14 @@ public class ScrubbersSample
|
|||
.ScrubEmptyLines();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Scrubbers/ScrubbersSample.cs#L1-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberssamplefixie' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Scrubbers/ScrubbersSample.cs#L1-L111' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubbersSampleFixie' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### MSTest
|
||||
|
||||
<!-- snippet: ScrubbersSampleMSTest -->
|
||||
<a id='snippet-scrubberssamplemstest'></a>
|
||||
<a id='snippet-ScrubbersSampleMSTest'></a>
|
||||
```cs
|
||||
[TestClass]
|
||||
public class ScrubbersSample :
|
||||
|
@ -635,7 +635,7 @@ public class ScrubbersSample :
|
|||
.ScrubEmptyLines();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.MSTest.Tests/Scrubbers/ScrubbersSample.cs#L3-L121' 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-L121' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubbersSampleMSTest' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -675,7 +675,7 @@ Scrubbers can be defined at three levels:
|
|||
### NUnit
|
||||
|
||||
<!-- snippet: ScrubberLevelsSampleNUnit -->
|
||||
<a id='snippet-scrubberlevelssamplenunit'></a>
|
||||
<a id='snippet-ScrubberLevelsSampleNUnit'></a>
|
||||
```cs
|
||||
[TestFixture]
|
||||
public class ScrubberLevelsSample
|
||||
|
@ -706,14 +706,14 @@ public class ScrubberLevelsSample
|
|||
VerifierSettings.AddScrubber(_ => _.Replace("One", "A"));
|
||||
}
|
||||
```
|
||||
<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>
|
||||
<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 -->
|
||||
|
||||
|
||||
### xUnit
|
||||
|
||||
<!-- snippet: ScrubberLevelsSampleXunit -->
|
||||
<a id='snippet-scrubberlevelssamplexunit'></a>
|
||||
<a id='snippet-ScrubberLevelsSampleXunit'></a>
|
||||
```cs
|
||||
public class ScrubberLevelsSample
|
||||
{
|
||||
|
@ -743,14 +743,14 @@ public class ScrubberLevelsSample
|
|||
VerifierSettings.AddScrubber(_ => _.Replace("One", "A"));
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L31' 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-L31' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubberLevelsSampleXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Fixie
|
||||
|
||||
<!-- snippet: ScrubberLevelsSampleFixie -->
|
||||
<a id='snippet-scrubberlevelssamplefixie'></a>
|
||||
<a id='snippet-ScrubberLevelsSampleFixie'></a>
|
||||
```cs
|
||||
public class ScrubberLevelsSample
|
||||
{
|
||||
|
@ -778,14 +778,14 @@ public class ScrubberLevelsSample
|
|||
VerifierSettings.AddScrubber(_ => _.Replace("One", "A"));
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubberlevelssamplefixie' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Fixie.Tests/Scrubbers/ScrubberLevelsSample.cs#L1-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubberLevelsSampleFixie' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### MSTest
|
||||
|
||||
<!-- snippet: ScrubberLevelsSampleMSTest -->
|
||||
<a id='snippet-scrubberlevelssamplemstest'></a>
|
||||
<a id='snippet-ScrubberLevelsSampleMSTest'></a>
|
||||
```cs
|
||||
[TestClass]
|
||||
public class ScrubberLevelsSample :
|
||||
|
@ -817,7 +817,7 @@ public class ScrubberLevelsSample :
|
|||
VerifierSettings.AddScrubber(_ => _.Replace("One", "A"));
|
||||
}
|
||||
```
|
||||
<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>
|
||||
<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 -->
|
||||
|
||||
|
||||
|
|
|
@ -31,13 +31,13 @@ The reason for these is that it makes approval files cleaner and easier to read
|
|||
To use strict json call `VerifierSettings.UseStrictJson`:
|
||||
|
||||
<!-- snippet: UseStrictJson -->
|
||||
<a id='snippet-usestrictjson'></a>
|
||||
<a id='snippet-UseStrictJson'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void Init() =>
|
||||
VerifierSettings.UseStrictJson();
|
||||
```
|
||||
<sup><a href='/src/StrictJsonTests/ModuleInit.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-usestrictjson' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/StrictJsonTests/ModuleInit.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseStrictJson' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Then this result in
|
||||
|
@ -49,7 +49,7 @@ Then this result in
|
|||
Then when an object is verified:
|
||||
|
||||
<!-- snippet: UseStrictJsonVerify -->
|
||||
<a id='snippet-usestrictjsonverify'></a>
|
||||
<a id='snippet-UseStrictJsonVerify'></a>
|
||||
```cs
|
||||
var target = new TheTarget
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ var target = new TheTarget
|
|||
};
|
||||
await Verify(target);
|
||||
```
|
||||
<sup><a href='/src/StrictJsonTests/Tests.cs#L82-L90' 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#L82-L90' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseStrictJsonVerify' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
The resulting file will be:
|
||||
|
@ -78,7 +78,7 @@ The resulting file will be:
|
|||
The default encoding for snapshot files uses UTF-8 with byte order marks (BOM) enable. To disable UTF-8 BOMs, call `VerifierSettings.UseUtf8NoBom`.
|
||||
|
||||
<!-- snippet: UseUtf8NoBom -->
|
||||
<a id='snippet-useutf8nobom'></a>
|
||||
<a id='snippet-UseUtf8NoBom'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ public static class ModuleInitializer
|
|||
VerifierSettings.UseUtf8NoBom();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/ModuleInitDocs/UseUtf8NoBom.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-useutf8nobom' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/ModuleInitDocs/UseUtf8NoBom.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseUtf8NoBom' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -96,7 +96,7 @@ public static class ModuleInitializer
|
|||
To override the encoding used for snapshot files, replacing the default UTF-8 encoding, call `VerifierSettings.UseEncoding` providing a `System.Text.Encoding` instance.
|
||||
|
||||
<!-- snippet: UseEncoding -->
|
||||
<a id='snippet-useencoding'></a>
|
||||
<a id='snippet-UseEncoding'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -111,7 +111,7 @@ public static class ModuleInitializer
|
|||
}
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/ModuleInitDocs/UseEncoding.cs#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-useencoding' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/ModuleInitDocs/UseEncoding.cs#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseEncoding' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -126,7 +126,7 @@ See [Argon documentation](https://github.com/SimonCropp/Argon/blob/main/docs/rea
|
|||
The default `JsonSerializerSettings` are:
|
||||
|
||||
<!-- snippet: defaultSerialization -->
|
||||
<a id='snippet-defaultserialization'></a>
|
||||
<a id='snippet-defaultSerialization'></a>
|
||||
```cs
|
||||
var settings = new JsonSerializerSettings
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ var settings = new JsonSerializerSettings
|
|||
DefaultValueHandling = DefaultValueHandling.Ignore
|
||||
};
|
||||
```
|
||||
<sup><a href='/src/Verify/Serialization/SerializationSettings.cs#L81-L90' 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#L81-L90' title='Snippet source file'>snippet source</a> | <a href='#snippet-defaultSerialization' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -145,20 +145,20 @@ var settings = new JsonSerializerSettings
|
|||
#### Globally
|
||||
|
||||
<!-- snippet: AddExtraSettingsGlobal -->
|
||||
<a id='snippet-addextrasettingsglobal'></a>
|
||||
<a id='snippet-AddExtraSettingsGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings
|
||||
.AddExtraSettings(_ =>
|
||||
_.TypeNameHandling = TypeNameHandling.All);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L610-L616' 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#L610-L616' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddExtraSettingsGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
#### Instance
|
||||
|
||||
<!-- snippet: AddExtraSettings -->
|
||||
<a id='snippet-addextrasettings'></a>
|
||||
<a id='snippet-AddExtraSettings'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task AddExtraSettings()
|
||||
|
@ -171,14 +171,14 @@ public Task AddExtraSettings()
|
|||
return Verify("Value", settings);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L580-L593' 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#L580-L593' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddExtraSettings' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
#### Fluent
|
||||
|
||||
<!-- snippet: AddExtraSettingsFluent -->
|
||||
<a id='snippet-addextrasettingsfluent'></a>
|
||||
<a id='snippet-AddExtraSettingsFluent'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task AddExtraSettingsFluent() =>
|
||||
|
@ -187,7 +187,7 @@ public Task AddExtraSettingsFluent() =>
|
|||
_ => _.Error = (currentObject, originalObject, location, exception, handled) =>
|
||||
Console.WriteLine(location.Member));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L595-L604' 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#L595-L604' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddExtraSettingsFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -203,11 +203,11 @@ By default empty collections are ignored during verification.
|
|||
To disable this behavior globally use:
|
||||
|
||||
<!-- snippet: DontIgnoreEmptyCollections -->
|
||||
<a id='snippet-dontignoreemptycollections'></a>
|
||||
<a id='snippet-DontIgnoreEmptyCollections'></a>
|
||||
```cs
|
||||
VerifierSettings.DontIgnoreEmptyCollections();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1563-L1567' 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#L1563-L1567' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontIgnoreEmptyCollections' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -219,25 +219,25 @@ Extra Json.NET settings can be made:
|
|||
### Globally
|
||||
|
||||
<!-- snippet: ExtraSettingsGlobal -->
|
||||
<a id='snippet-extrasettingsglobal'></a>
|
||||
<a id='snippet-ExtraSettingsGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.AddExtraSettings(
|
||||
_ => _.TypeNameHandling = TypeNameHandling.All);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L128-L133' title='Snippet source file'>snippet source</a> | <a href='#snippet-extrasettingsglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L128-L133' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExtraSettingsGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Instance
|
||||
|
||||
<!-- snippet: ExtraSettingsInstance -->
|
||||
<a id='snippet-extrasettingsinstance'></a>
|
||||
<a id='snippet-ExtraSettingsInstance'></a>
|
||||
```cs
|
||||
var settings = new VerifySettings();
|
||||
settings.AddExtraSettings(
|
||||
_ => _.TypeNameHandling = TypeNameHandling.All);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L135-L141' title='Snippet source file'>snippet source</a> | <a href='#snippet-extrasettingsinstance' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L135-L141' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExtraSettingsInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -246,7 +246,7 @@ settings.AddExtraSettings(
|
|||
One common use case is to register a custom [JsonConverter](https://www.newtonsoft.com/json/help/html/CustomJsonConverter.htm). As only writing is required, to help with this there is `WriteOnlyJsonConverter`, and `WriteOnlyJsonConverter<T>`.
|
||||
|
||||
<!-- snippet: CompanyConverter -->
|
||||
<a id='snippet-companyconverter'></a>
|
||||
<a id='snippet-CompanyConverter'></a>
|
||||
```cs
|
||||
class CompanyConverter :
|
||||
WriteOnlyJsonConverter<Company>
|
||||
|
@ -255,16 +255,16 @@ class CompanyConverter :
|
|||
writer.WriteMember(company, company.Name, "Name");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L155-L164' 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#L155-L164' title='Snippet source file'>snippet source</a> | <a href='#snippet-CompanyConverter' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: JsonConverter -->
|
||||
<a id='snippet-jsonconverter'></a>
|
||||
<a id='snippet-JsonConverter'></a>
|
||||
```cs
|
||||
VerifierSettings.AddExtraSettings(
|
||||
_ => _.Converters.Add(new CompanyConverter()));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L147-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-jsonconverter' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L147-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-JsonConverter' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -281,7 +281,7 @@ VerifierSettings.AddExtraSettings(
|
|||
## Scoped settings
|
||||
|
||||
<!-- snippet: ScopedSerializer -->
|
||||
<a id='snippet-scopedserializer'></a>
|
||||
<a id='snippet-ScopedSerializer'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScopedSerializer()
|
||||
|
@ -308,7 +308,7 @@ public Task ScopedSerializerFluent()
|
|||
.AddExtraSettings(_ => _.TypeNameHandling = TypeNameHandling.All);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3695-L3722' 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#L3695-L3722' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScopedSerializer' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -331,7 +331,7 @@ Result:
|
|||
To ignore all members that match a certain type:
|
||||
|
||||
<!-- snippet: AddIgnoreType -->
|
||||
<a id='snippet-addignoretype'></a>
|
||||
<a id='snippet-AddIgnoreType'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task IgnoreType()
|
||||
|
@ -436,17 +436,17 @@ public Task IgnoreTypeFluent()
|
|||
.IgnoreMembersWithType<ToIgnoreStruct>();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2726-L2831' 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#L2726-L2831' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddIgnoreType' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: AddIgnoreTypeGlobal -->
|
||||
<a id='snippet-addignoretypeglobal'></a>
|
||||
<a id='snippet-AddIgnoreTypeGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.IgnoreMembersWithType<ToIgnore>();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2713-L2717' 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#L2713-L2717' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddIgnoreTypeGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -478,7 +478,7 @@ Result:
|
|||
To scrub all members that match a certain type:
|
||||
|
||||
<!-- snippet: AddScrubType -->
|
||||
<a id='snippet-addscrubtype'></a>
|
||||
<a id='snippet-AddScrubType'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubType()
|
||||
|
@ -583,17 +583,17 @@ public Task ScrubTypeFluent()
|
|||
.ScrubMembersWithType<ToIgnoreStruct>();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2834-L2939' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubtype' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2834-L2939' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddScrubType' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: AddScrubTypeGlobal -->
|
||||
<a id='snippet-addscrubtypeglobal'></a>
|
||||
<a id='snippet-AddScrubTypeGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.ScrubMembersWithType<ToIgnore>();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2719-L2723' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubtypeglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2719-L2723' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddScrubTypeGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -633,7 +633,7 @@ Result:
|
|||
To ignore instances of a type based on delegate:
|
||||
|
||||
<!-- snippet: AddIgnoreInstance -->
|
||||
<a id='snippet-addignoreinstance'></a>
|
||||
<a id='snippet-AddIgnoreInstance'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task AddIgnoreInstance()
|
||||
|
@ -672,17 +672,17 @@ public Task AddIgnoreInstanceFluent()
|
|||
.IgnoreInstance<Instance>(_ => _.Property == "Ignore");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2599-L2638' 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#L2599-L2638' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddIgnoreInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: AddIgnoreInstanceGlobal -->
|
||||
<a id='snippet-addignoreinstanceglobal'></a>
|
||||
<a id='snippet-AddIgnoreInstanceGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.IgnoreInstance<Instance>(_ => _.Property == "Ignore");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2586-L2590' 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#L2586-L2590' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddIgnoreInstanceGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -705,7 +705,7 @@ Result:
|
|||
To scrub instances of a type based on delegate:
|
||||
|
||||
<!-- snippet: AddScrubInstance -->
|
||||
<a id='snippet-addscrubinstance'></a>
|
||||
<a id='snippet-AddScrubInstance'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task AddScrubInstance()
|
||||
|
@ -744,17 +744,17 @@ public Task AddScrubInstanceFluent()
|
|||
.ScrubInstance<Instance>(_ => _.Property == "Ignore");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2640-L2679' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubinstance' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2640-L2679' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddScrubInstance' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: AddScrubInstanceGlobal -->
|
||||
<a id='snippet-addscrubinstanceglobal'></a>
|
||||
<a id='snippet-AddScrubInstanceGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.ScrubInstance<Instance>(_ => _.Property == "Ignore");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2592-L2596' title='Snippet source file'>snippet source</a> | <a href='#snippet-addscrubinstanceglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2592-L2596' title='Snippet source file'>snippet source</a> | <a href='#snippet-AddScrubInstanceGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -778,7 +778,7 @@ Result:
|
|||
Members with an [ObsoleteAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.obsoleteattribute) are ignored:
|
||||
|
||||
<!-- snippet: WithObsoleteProp -->
|
||||
<a id='snippet-withobsoleteprop'></a>
|
||||
<a id='snippet-WithObsoleteProp'></a>
|
||||
```cs
|
||||
class WithObsolete
|
||||
{
|
||||
|
@ -799,7 +799,7 @@ public Task WithObsoleteProp()
|
|||
return Verify(target);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3660-L3681' 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#L3660-L3681' title='Snippet source file'>snippet source</a> | <a href='#snippet-WithObsoleteProp' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -820,7 +820,7 @@ Result:
|
|||
Obsolete members can be included using `IncludeObsoletes`:
|
||||
|
||||
<!-- snippet: WithObsoletePropIncluded -->
|
||||
<a id='snippet-withobsoletepropincluded'></a>
|
||||
<a id='snippet-WithObsoletePropIncluded'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task WithObsoletePropIncluded()
|
||||
|
@ -847,17 +847,17 @@ public Task WithObsoletePropIncludedFluent()
|
|||
.IncludeObsoletes();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3631-L3658' 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#L3631-L3658' title='Snippet source file'>snippet source</a> | <a href='#snippet-WithObsoletePropIncluded' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: WithObsoletePropIncludedGlobally -->
|
||||
<a id='snippet-withobsoletepropincludedglobally'></a>
|
||||
<a id='snippet-WithObsoletePropIncludedGlobally'></a>
|
||||
```cs
|
||||
VerifierSettings.IncludeObsoletes();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3624-L3628' 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#L3624-L3628' title='Snippet source file'>snippet source</a> | <a href='#snippet-WithObsoletePropIncludedGlobally' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -879,7 +879,7 @@ Result:
|
|||
To ignore members of a certain type using an expression:
|
||||
|
||||
<!-- snippet: IgnoreMemberByExpression -->
|
||||
<a id='snippet-ignorememberbyexpression'></a>
|
||||
<a id='snippet-IgnoreMemberByExpression'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task IgnoreMemberByExpression()
|
||||
|
@ -918,13 +918,13 @@ public Task IgnoreMemberByExpressionFluent()
|
|||
_ => _.PropertyThatThrows);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3142-L3181' 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#L3142-L3181' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMemberByExpression' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally
|
||||
|
||||
<!-- snippet: IgnoreMemberByExpressionGlobal -->
|
||||
<a id='snippet-ignorememberbyexpressionglobal'></a>
|
||||
<a id='snippet-IgnoreMemberByExpressionGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.IgnoreMembers<IgnoreExplicitTarget>(
|
||||
_ => _.Property,
|
||||
|
@ -933,7 +933,7 @@ VerifierSettings.IgnoreMembers<IgnoreExplicitTarget>(
|
|||
_ => _.GetOnlyProperty,
|
||||
_ => _.PropertyThatThrows);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3119-L3128' 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#L3119-L3128' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMemberByExpressionGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -954,7 +954,7 @@ Result:
|
|||
To scrub members of a certain type using an expression:
|
||||
|
||||
<!-- snippet: ScrubMemberByExpression -->
|
||||
<a id='snippet-scrubmemberbyexpression'></a>
|
||||
<a id='snippet-ScrubMemberByExpression'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubMemberByExpression()
|
||||
|
@ -993,13 +993,13 @@ public Task ScrubMemberByExpressionFluent()
|
|||
_ => _.PropertyThatThrows);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3183-L3222' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyexpression' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3183-L3222' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMemberByExpression' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally
|
||||
|
||||
<!-- snippet: ScrubMemberByExpressionGlobal -->
|
||||
<a id='snippet-scrubmemberbyexpressionglobal'></a>
|
||||
<a id='snippet-ScrubMemberByExpressionGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.ScrubMembers<IgnoreExplicitTarget>(
|
||||
_ => _.Property,
|
||||
|
@ -1008,7 +1008,7 @@ VerifierSettings.ScrubMembers<IgnoreExplicitTarget>(
|
|||
_ => _.GetOnlyProperty,
|
||||
_ => _.PropertyThatThrows);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3130-L3139' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyexpressionglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3130-L3139' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMemberByExpressionGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -1034,7 +1034,7 @@ Result:
|
|||
To ignore members of a certain type using type and name:
|
||||
|
||||
<!-- snippet: IgnoreMemberByName -->
|
||||
<a id='snippet-ignorememberbyname'></a>
|
||||
<a id='snippet-IgnoreMemberByName'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task IgnoreMemberByName()
|
||||
|
@ -1087,13 +1087,13 @@ public Task IgnoreMemberByNameFluent()
|
|||
.IgnoreMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3296-L3349' 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#L3296-L3349' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMemberByName' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: IgnoreMemberByNameGlobal -->
|
||||
<a id='snippet-ignorememberbynameglobal'></a>
|
||||
<a id='snippet-IgnoreMemberByNameGlobal'></a>
|
||||
```cs
|
||||
// For all types
|
||||
VerifierSettings.IgnoreMember("PropertyByName");
|
||||
|
@ -1107,7 +1107,7 @@ VerifierSettings.IgnoreMember<IgnoreExplicitTarget>("Field");
|
|||
// For a specific type with expression
|
||||
VerifierSettings.IgnoreMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3263-L3277' 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#L3263-L3277' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMemberByNameGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -1129,7 +1129,7 @@ Result:
|
|||
To scrub members of a certain type using type and name:
|
||||
|
||||
<!-- snippet: ScrubMemberByName -->
|
||||
<a id='snippet-scrubmemberbyname'></a>
|
||||
<a id='snippet-ScrubMemberByName'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ScrubMemberByName()
|
||||
|
@ -1182,13 +1182,13 @@ public Task ScrubMemberByNameFluent()
|
|||
.ScrubMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3351-L3404' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbyname' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3351-L3404' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMemberByName' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: ScrubMemberByNameGlobal -->
|
||||
<a id='snippet-scrubmemberbynameglobal'></a>
|
||||
<a id='snippet-ScrubMemberByNameGlobal'></a>
|
||||
```cs
|
||||
// For all types
|
||||
VerifierSettings.ScrubMember("PropertyByName");
|
||||
|
@ -1202,7 +1202,7 @@ VerifierSettings.ScrubMember<IgnoreExplicitTarget>("Field");
|
|||
// For a specific type with expression
|
||||
VerifierSettings.ScrubMember<IgnoreExplicitTarget>(_ => _.PropertyThatThrows);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3279-L3293' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubmemberbynameglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3279-L3293' title='Snippet source file'>snippet source</a> | <a href='#snippet-ScrubMemberByNameGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -1234,7 +1234,7 @@ Note that this is global for all members on all types.
|
|||
Ignore by exception type:
|
||||
|
||||
<!-- snippet: IgnoreMembersThatThrow -->
|
||||
<a id='snippet-ignoremembersthatthrow'></a>
|
||||
<a id='snippet-IgnoreMembersThatThrow'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task CustomExceptionProp()
|
||||
|
@ -1253,17 +1253,17 @@ public Task CustomExceptionPropFluent()
|
|||
.IgnoreMembersThatThrow<CustomException>();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3512-L3531' 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#L3512-L3531' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMembersThatThrow' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: IgnoreMembersThatThrowGlobal -->
|
||||
<a id='snippet-ignoremembersthatthrowglobal'></a>
|
||||
<a id='snippet-IgnoreMembersThatThrowGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.IgnoreMembersThatThrow<CustomException>();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3505-L3509' 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#L3505-L3509' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMembersThatThrowGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -1279,7 +1279,7 @@ Result:
|
|||
Ignore by exception type and expression:
|
||||
|
||||
<!-- snippet: IgnoreMembersThatThrowExpression -->
|
||||
<a id='snippet-ignoremembersthatthrowexpression'></a>
|
||||
<a id='snippet-IgnoreMembersThatThrowExpression'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task ExceptionMessageProp()
|
||||
|
@ -1300,17 +1300,17 @@ public Task ExceptionMessagePropFluent()
|
|||
.IgnoreMembersThatThrow<Exception>(_ => _.Message == "Ignore");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2374-L2395' 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#L2374-L2395' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMembersThatThrowExpression' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Or globally:
|
||||
|
||||
<!-- snippet: IgnoreMembersThatThrowExpressionGlobal -->
|
||||
<a id='snippet-ignoremembersthatthrowexpressionglobal'></a>
|
||||
<a id='snippet-IgnoreMembersThatThrowExpressionGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.IgnoreMembersThatThrow<Exception>(_ => _.Message == "Ignore");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L2367-L2371' 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#L2367-L2371' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreMembersThatThrowExpressionGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Result:
|
||||
|
@ -1331,7 +1331,7 @@ Certain types, when passed directly in to Verify, are written directly without g
|
|||
The default mapping is:
|
||||
|
||||
<!-- snippet: typeToStringMapping -->
|
||||
<a id='snippet-typetostringmapping'></a>
|
||||
<a id='snippet-typeToStringMapping'></a>
|
||||
```cs
|
||||
{
|
||||
typeof(StringBuilder), (target, _) => ((StringBuilder) target).ToString()
|
||||
|
@ -1418,7 +1418,7 @@ The default mapping is:
|
|||
}
|
||||
},
|
||||
```
|
||||
<sup><a href='/src/Verify/Serialization/VerifierSettings.cs#L38-L125' title='Snippet source file'>snippet source</a> | <a href='#snippet-typetostringmapping' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify/Serialization/VerifierSettings.cs#L38-L125' title='Snippet source file'>snippet source</a> | <a href='#snippet-typeToStringMapping' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
This bypasses the Guid and DateTime scrubbing.
|
||||
|
@ -1426,12 +1426,12 @@ This bypasses the Guid and DateTime scrubbing.
|
|||
Extra types can be added to this mapping:
|
||||
|
||||
<!-- snippet: TreatAsString -->
|
||||
<a id='snippet-treatasstring'></a>
|
||||
<a id='snippet-TreatAsString'></a>
|
||||
```cs
|
||||
VerifierSettings.TreatAsString<ClassWithToString>(
|
||||
(target, settings) => target.Property);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L67-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-treatasstring' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L67-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-TreatAsString' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -1440,7 +1440,7 @@ VerifierSettings.TreatAsString<ClassWithToString>(
|
|||
The value of a member can be mutated before serialization:
|
||||
|
||||
<!-- snippet: MemberConverter -->
|
||||
<a id='snippet-memberconverter'></a>
|
||||
<a id='snippet-MemberConverter'></a>
|
||||
```cs
|
||||
[ModuleInitializer]
|
||||
public static void MemberConverterByExpressionInit()
|
||||
|
@ -1468,7 +1468,7 @@ public Task MemberConverterByExpression()
|
|||
return Verify(input);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L3224-L3252' 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#L3224-L3252' title='Snippet source file'>snippet source</a> | <a href='#snippet-MemberConverter' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -1477,7 +1477,7 @@ public Task MemberConverterByExpression()
|
|||
Serialized properties can optionally be sorted alphabetically, ie ignoring the order they are defined when using reflection.
|
||||
|
||||
<!-- snippet: SortProperties -->
|
||||
<a id='snippet-sortproperties'></a>
|
||||
<a id='snippet-SortProperties'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -1486,7 +1486,7 @@ public static class ModuleInitializer
|
|||
VerifierSettings.SortPropertiesAlphabetically();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/ModuleInitDocs/SortedProperties.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-sortproperties' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/ModuleInitDocs/SortedProperties.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-SortProperties' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -1497,7 +1497,7 @@ Dictionaries are sorted by key.
|
|||
To disable use:
|
||||
|
||||
<!-- snippet: DontSortDictionaries -->
|
||||
<a id='snippet-dontsortdictionaries'></a>
|
||||
<a id='snippet-DontSortDictionaries'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task DontSortDictionaries()
|
||||
|
@ -1519,7 +1519,7 @@ public Task DontSortDictionaries()
|
|||
.DontSortDictionaries();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L241-L263' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontsortdictionaries' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L241-L263' title='Snippet source file'>snippet source</a> | <a href='#snippet-DontSortDictionaries' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -1530,7 +1530,7 @@ Json and JObject are not sorted.
|
|||
To enable sorting use:
|
||||
|
||||
<!-- snippet: SortJsonObjects -->
|
||||
<a id='snippet-sortjsonobjects'></a>
|
||||
<a id='snippet-SortJsonObjects'></a>
|
||||
```cs
|
||||
public static class ModuleInitializer
|
||||
{
|
||||
|
@ -1539,7 +1539,7 @@ public static class ModuleInitializer
|
|||
VerifierSettings.SortJsonObjects();
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/ModuleInitDocs/SortedJson.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-sortjsonobjects' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/ModuleInitDocs/SortedJson.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-SortJsonObjects' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -1550,7 +1550,7 @@ A JsonAppender allows extra content (key value pairs) to be optionally appended
|
|||
Register a JsonAppender:
|
||||
|
||||
<!-- snippet: RegisterJsonAppender -->
|
||||
<a id='snippet-registerjsonappender'></a>
|
||||
<a id='snippet-RegisterJsonAppender'></a>
|
||||
```cs
|
||||
VerifierSettings.RegisterJsonAppender(
|
||||
context =>
|
||||
|
@ -1563,19 +1563,19 @@ VerifierSettings.RegisterJsonAppender(
|
|||
return null;
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L8-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerjsonappender' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L8-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-RegisterJsonAppender' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
When when content is verified:
|
||||
|
||||
<!-- snippet: JsonAppender -->
|
||||
<a id='snippet-jsonappender'></a>
|
||||
<a id='snippet-JsonAppender'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task WithJsonAppender() =>
|
||||
Verify("TheValue");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L34-L40' 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#L34-L40' 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:
|
||||
|
@ -1594,13 +1594,13 @@ The content from RegisterJsonAppender will be included in the output:
|
|||
If the target is a stream or binary file:
|
||||
|
||||
<!-- snippet: JsonAppenderStream -->
|
||||
<a id='snippet-jsonappenderstream'></a>
|
||||
<a id='snippet-JsonAppenderStream'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task Stream() =>
|
||||
Verify(IoHelpers.OpenRead("sample.txt"));
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/Converters/JsonAppenderTests.cs#L68-L74' 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#L68-L74' 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 `.verified.txt` file:
|
||||
|
|
|
@ -10,24 +10,24 @@ To change this file edit the source file and then run MarkdownSnippets.
|
|||
Given a method that throws an Exception
|
||||
|
||||
<!-- snippet: MethodThatThrows -->
|
||||
<a id='snippet-methodthatthrows'></a>
|
||||
<a id='snippet-MethodThatThrows'></a>
|
||||
```cs
|
||||
static void MethodThatThrows() =>
|
||||
throw new("The Message");
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L45-L50' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodthatthrows' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L45-L50' title='Snippet source file'>snippet source</a> | <a href='#snippet-MethodThatThrows' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
That exception behavior can be verified using `Verify.Throws`:
|
||||
|
||||
<!-- snippet: TestMethodThatThrows -->
|
||||
<a id='snippet-testmethodthatthrows'></a>
|
||||
<a id='snippet-TestMethodThatThrows'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task TestMethodThatThrows() =>
|
||||
Throws(MethodThatThrows);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L7-L13' title='Snippet source file'>snippet source</a> | <a href='#snippet-testmethodthatthrows' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L7-L13' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestMethodThatThrows' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
Resulting in the following snapshot file:
|
||||
|
@ -53,21 +53,21 @@ Often the exception stack trace can be noisy and fragile to causing false failed
|
|||
### Fluent API
|
||||
|
||||
<!-- snippet: TestMethodThatThrowsIgnoreStackTraceFluent -->
|
||||
<a id='snippet-testmethodthatthrowsignorestacktracefluent'></a>
|
||||
<a id='snippet-TestMethodThatThrowsIgnoreStackTraceFluent'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task TestMethodThatThrowsIgnoreStackTraceFluent() =>
|
||||
Throws(MethodThatThrows)
|
||||
.IgnoreStackTrace();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L15-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-testmethodthatthrowsignorestacktracefluent' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L15-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestMethodThatThrowsIgnoreStackTraceFluent' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Settings api
|
||||
|
||||
<!-- snippet: TestMethodThatThrowsIgnoreStackTraceSettings -->
|
||||
<a id='snippet-testmethodthatthrowsignorestacktracesettings'></a>
|
||||
<a id='snippet-TestMethodThatThrowsIgnoreStackTraceSettings'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task TestMethodThatThrowsIgnoreStackTraceSettings()
|
||||
|
@ -77,18 +77,18 @@ public Task TestMethodThatThrowsIgnoreStackTraceSettings()
|
|||
return Throws(MethodThatThrows, settings);
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L24-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-testmethodthatthrowsignorestacktracesettings' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L24-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestMethodThatThrowsIgnoreStackTraceSettings' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### Globally
|
||||
|
||||
<!-- snippet: IgnoreStackTraceGlobal -->
|
||||
<a id='snippet-ignorestacktraceglobal'></a>
|
||||
<a id='snippet-IgnoreStackTraceGlobal'></a>
|
||||
```cs
|
||||
VerifierSettings.IgnoreStackTrace();
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L38-L42' title='Snippet source file'>snippet source</a> | <a href='#snippet-ignorestacktraceglobal' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L38-L42' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreStackTraceGlobal' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -114,7 +114,7 @@ There are specific named `Throws*` method for methods that return a `Task` or a
|
|||
### Task
|
||||
|
||||
<!-- snippet: MethodThatThrowsTask -->
|
||||
<a id='snippet-methodthatthrowstask'></a>
|
||||
<a id='snippet-MethodThatThrowsTask'></a>
|
||||
```cs
|
||||
static async Task MethodThatThrowsTask()
|
||||
{
|
||||
|
@ -122,24 +122,24 @@ static async Task MethodThatThrowsTask()
|
|||
throw new("The Message");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L62-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodthatthrowstask' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L62-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-MethodThatThrowsTask' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: TestMethodThatThrowsTask -->
|
||||
<a id='snippet-testmethodthatthrowstask'></a>
|
||||
<a id='snippet-TestMethodThatThrowsTask'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task TestMethodThatThrowsTask() =>
|
||||
ThrowsTask(MethodThatThrowsTask);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L54-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-testmethodthatthrowstask' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L54-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestMethodThatThrowsTask' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
### ValueTask
|
||||
|
||||
<!-- snippet: MethodThatThrowsValueTask -->
|
||||
<a id='snippet-methodthatthrowsvaluetask'></a>
|
||||
<a id='snippet-MethodThatThrowsValueTask'></a>
|
||||
```cs
|
||||
static async ValueTask MethodThatThrowsValueTask()
|
||||
{
|
||||
|
@ -147,15 +147,15 @@ static async ValueTask MethodThatThrowsValueTask()
|
|||
throw new("The Message");
|
||||
}
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L80-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-methodthatthrowsvaluetask' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L80-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-MethodThatThrowsValueTask' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
<!-- snippet: TestMethodThatThrowsValueTask -->
|
||||
<a id='snippet-testmethodthatthrowsvaluetask'></a>
|
||||
<a id='snippet-TestMethodThatThrowsValueTask'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task TestMethodThatThrowsValueTask() =>
|
||||
ThrowsValueTask(MethodThatThrowsValueTask);
|
||||
```
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L72-L78' title='Snippet source file'>snippet source</a> | <a href='#snippet-testmethodthatthrowsvaluetask' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Tests/ThrowsTests.cs#L72-L78' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestMethodThatThrowsValueTask' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
|
|
@ -10,20 +10,20 @@ To change this file edit the source file and then run MarkdownSnippets.
|
|||
Verifies all files in a directory. This approach combines [UseUniqueDirectory](/docs/naming.md#useuniquedirectory) with a target per file, to snapshot test all files in a directory.
|
||||
|
||||
<!-- snippet: VerifyDirectoryXunit -->
|
||||
<a id='snippet-verifydirectoryxunit'></a>
|
||||
<a id='snippet-VerifyDirectoryXunit'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task WithDirectory() =>
|
||||
VerifyDirectory(directoryToVerify);
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L102-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifydirectoryxunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L102-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyDirectoryXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
## Filtering
|
||||
|
||||
<!-- snippet: VerifyDirectoryFilterXunit -->
|
||||
<a id='snippet-verifydirectoryfilterxunit'></a>
|
||||
<a id='snippet-VerifyDirectoryFilterXunit'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task WithDirectoryFiltered() =>
|
||||
|
@ -36,7 +36,7 @@ public Task WithDirectoryFiltered() =>
|
|||
RecurseSubdirectories = false
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L139-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifydirectoryfilterxunit' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L139-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyDirectoryFilterXunit' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -45,7 +45,7 @@ public Task WithDirectoryFiltered() =>
|
|||
An optional `info` parameter can be supplied to add more context to the test. The instance passed will be json serialized.
|
||||
|
||||
<!-- snippet: VerifyDirectoryWithInfo -->
|
||||
<a id='snippet-verifydirectorywithinfo'></a>
|
||||
<a id='snippet-VerifyDirectoryWithInfo'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task VerifyDirectoryWithInfo() =>
|
||||
|
@ -53,7 +53,7 @@ public Task VerifyDirectoryWithInfo() =>
|
|||
directoryToVerify,
|
||||
info: "the info");
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L110-L118' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifydirectorywithinfo' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L110-L118' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyDirectoryWithInfo' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
|
||||
|
@ -62,7 +62,7 @@ public Task VerifyDirectoryWithInfo() =>
|
|||
`VerifyDirectory` has an optional parameter `fileScrubber` that allows file specific scrubbing:
|
||||
|
||||
<!-- snippet: VerifyDirectoryWithFileScrubber -->
|
||||
<a id='snippet-verifydirectorywithfilescrubber'></a>
|
||||
<a id='snippet-VerifyDirectoryWithFileScrubber'></a>
|
||||
```cs
|
||||
[Fact]
|
||||
public Task VerifyDirectoryWithFileScrubber() =>
|
||||
|
@ -77,7 +77,7 @@ public Task VerifyDirectoryWithFileScrubber() =>
|
|||
}
|
||||
});
|
||||
```
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L120-L135' title='Snippet source file'>snippet source</a> | <a href='#snippet-verifydirectorywithfilescrubber' title='Start of snippet'>anchor</a></sup>
|
||||
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L120-L135' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyDirectoryWithFileScrubber' title='Start of snippet'>anchor</a></sup>
|
||||
<!-- endSnippet -->
|
||||
|
||||
This applies to files where the extensins is a known text file as defined by [FileExtensions.IsText](https://github.com/VerifyTests/EmptyFiles#istext).
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче