Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Mar 27, 2024
1 parent 964c604 commit 9f8743c
Show file tree
Hide file tree
Showing 346 changed files with 1,056 additions and 1,056 deletions.
16 changes: 8 additions & 8 deletions docs/anonymous-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When validating multiple instances, an [anonymous type](https://docs.microsoft.c
## NUnit

<!-- snippet: AnonNUnit -->
<a id='snippet-anonnunit'></a>
<a id='snippet-AnonNUnit'></a>
```cs
[Test]
public Task Anon()
Expand All @@ -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>
<a id='snippet-AnonXunit'></a>
```cs
[Fact]
public Task Anon()
Expand All @@ -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>
<a id='snippet-AnonFixie'></a>
```cs
public Task Anon()
{
Expand All @@ -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>
<a id='snippet-AnonMSTest'></a>
```cs
[TestMethod]
public Task Anon()
Expand All @@ -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 -->


Expand Down
8 changes: 4 additions & 4 deletions docs/append-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions docs/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 -->


Expand Down
4 changes: 2 additions & 2 deletions docs/build-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -100,5 +100,5 @@ if (BuildServerDetector.Detected)
});
}
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L56-L70' 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#L56-L70' title='Snippet source file'>snippet source</a> | <a href='#snippet-DerivePathInfoAppVeyor' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
4 changes: 2 additions & 2 deletions docs/clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -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#L30-L34' 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#L30-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-EnableClipboard' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
12 changes: 6 additions & 6 deletions docs/compared-to-assertion.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 -->


Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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`:
Expand Down
16 changes: 8 additions & 8 deletions docs/comparer.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand All @@ -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()
Expand All @@ -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);

Expand Down Expand Up @@ -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 -->


Expand Down
24 changes: 12 additions & 12 deletions docs/converter.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>(

Expand Down Expand Up @@ -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 -->


Expand All @@ -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",
Expand Down Expand Up @@ -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 -->


Expand All @@ -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,
Expand All @@ -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 -->


Expand Down
Loading

0 comments on commit 9f8743c

Please sign in to comment.