Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Dec 14, 2019
1 parent a522792 commit a2194e4
Show file tree
Hide file tree
Showing 58 changed files with 1,022 additions and 62 deletions.
39 changes: 37 additions & 2 deletions docs/anonymous-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,35 @@ var person2 = new Person
FamilyName = "Aguirre"
};

await Verifier.Verify(
new
{
person1,
person2
});
```
<sup><a href='/src/Verify.NUnit.Tests/VerifyObjectSamples.cs#L75-L95' title='File snippet `anon` was extracted from'>snippet source</a> | <a href='#snippet-anon' title='Navigate to start of snippet `anon`'>anchor</a></sup>
<a id='snippet-anon-1'/></a>
```cs
var person1 = new Person
{
GivenNames = "John",
FamilyName = "Smith"
};
var person2 = new Person
{
GivenNames = "Marianne",
FamilyName = "Aguirre"
};

await Verify(
new
{
person1,
person2
});
```
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.cs#L74-L94' title='File snippet `anon` was extracted from'>snippet source</a> | <a href='#snippet-anon' title='Navigate to start of snippet `anon`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.cs#L74-L94' title='File snippet `anon` was extracted from'>snippet source</a> | <a href='#snippet-anon-1' title='Navigate to start of snippet `anon`'>anchor</a></sup>
<!-- endsnippet -->

Results in the following:
Expand All @@ -49,5 +70,19 @@ Results in the following:
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.Anon.verified.txt#L1-L10' title='File snippet `VerifyObjectSamples.Anon.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-VerifyObjectSamples.Anon.verified.txt' title='Navigate to start of snippet `VerifyObjectSamples.Anon.verified.txt`'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/VerifyObjectSamples.Anon.verified.txt#L1-L10' title='File snippet `VerifyObjectSamples.Anon.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-VerifyObjectSamples.Anon.verified.txt' title='Navigate to start of snippet `VerifyObjectSamples.Anon.verified.txt`'>anchor</a></sup>
<a id='snippet-VerifyObjectSamples.Anon.verified.txt-1'/></a>
```txt
{
person1: {
GivenNames: 'John',
FamilyName: 'Smith'
},
person2: {
GivenNames: 'Marianne',
FamilyName: 'Aguirre'
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.Anon.verified.txt#L1-L10' title='File snippet `VerifyObjectSamples.Anon.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-VerifyObjectSamples.Anon.verified.txt-1' title='Navigate to start of snippet `VerifyObjectSamples.Anon.verified.txt`'>anchor</a></sup>
<!-- endsnippet -->
12 changes: 10 additions & 2 deletions docs/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ Binary data can be verified by passing a stream to `VerifyBinary`.
```cs
public async Task VerifyBinary(Stream input, VerifySettings? settings = null)
```
<sup><a href='/src/Verify/Verifier/Verifier_Stream.cs#L11-L15' title='File snippet `verifybinary` was extracted from'>snippet source</a> | <a href='#snippet-verifybinary' title='Navigate to start of snippet `verifybinary`'>anchor</a></sup>
<sup><a href='/src/Verify/Verifier/Verifier_Stream.cs#L11-L13' title='File snippet `verifybinary` was extracted from'>snippet source</a> | <a href='#snippet-verifybinary' title='Navigate to start of snippet `verifybinary`'>anchor</a></sup>
<a id='snippet-verifybinary-1'/></a>
```cs
public static async Task VerifyBinary(
Stream input,
VerifySettings? settings = null,
[CallerFilePath] string sourceFile = "")
```
<sup><a href='/src/Verify.NUnit/Verifier_Stream.cs#L11-L16' title='File snippet `verifybinary` was extracted from'>snippet source</a> | <a href='#snippet-verifybinary-1' title='Navigate to start of snippet `verifybinary`'>anchor</a></sup>
<a id='snippet-verifybinary-2'/></a>
```cs
public Task VerifyBinary(Stream input, VerifySettings? settings = null)
```
<sup><a href='/src/Verify.Xunit/VerifyBase_Stream.cs#L10-L12' title='File snippet `verifybinary` was extracted from'>snippet source</a> | <a href='#snippet-verifybinary-1' title='Navigate to start of snippet `verifybinary`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit/VerifyBase_Stream.cs#L10-L12' title='File snippet `verifybinary` was extracted from'>snippet source</a> | <a href='#snippet-verifybinary-2' title='Navigate to start of snippet `verifybinary`'>anchor</a></sup>
<!-- endsnippet -->

A [Diff Tool](diff-tool.md) will only be displayed if one can be found that supports the defined extension.
Expand Down
2 changes: 1 addition & 1 deletion docs/mdsource/naming.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ snippet: ExtensionSample.cs

Result in two files:

snippet: ExtensionSample.InheritedFromClass.verified.json
snippet: ExtensionSample.SharedClassLevelSettings.verified.json

snippet: ExtensionSample.AtMethod.verified.xml
112 changes: 95 additions & 17 deletions docs/naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,29 @@ UniqueFor allows for one or more delimiters to be added to the file name.
<!-- snippet: UniqueForSample -->
<a id='snippet-uniqueforsample'/></a>
```cs
[TestFixture]
public class UniqueForSample
{
[Test]
public Task Runtime()
{
var settings = new VerifySettings();
settings.UniqueForRuntime();
return Verifier.Verify("value", settings);
}

[Test]
public Task RuntimeAndVersion()
{
var settings = new VerifySettings();
settings.UniqueForRuntimeAndVersion();
return Verifier.Verify("value", settings);
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Snippets/UniqueForSample.cs#L6-L26' title='File snippet `uniqueforsample` was extracted from'>snippet source</a> | <a href='#snippet-uniqueforsample' title='Navigate to start of snippet `uniqueforsample`'>anchor</a></sup>
<a id='snippet-uniqueforsample-1'/></a>
```cs
public class UniqueForSample :
VerifyBase
{
Expand All @@ -52,7 +75,7 @@ public class UniqueForSample :
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L7-L32' title='File snippet `uniqueforsample` was extracted from'>snippet source</a> | <a href='#snippet-uniqueforsample' title='Navigate to start of snippet `uniqueforsample`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L7-L32' title='File snippet `uniqueforsample` was extracted from'>snippet source</a> | <a href='#snippet-uniqueforsample-1' title='Navigate to start of snippet `uniqueforsample`'>anchor</a></sup>
<!-- endsnippet -->

For a project that targets
Expand Down Expand Up @@ -86,22 +109,27 @@ Usage:
<a id='snippet-ExtensionSample.cs'/></a>
```cs
using System.Threading.Tasks;
using NUnit.Framework;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
using VerifyNUnit;

public class ExtensionSample :
VerifyBase
[TestFixture]
public class ExtensionSample
{
VerifySettings classLevelSettings;

[Fact]
public ExtensionSample()
{
classLevelSettings = new VerifySettings();
classLevelSettings.UseExtension("json");
}

[Test]
public async Task AtMethod()
{
var settings = new VerifySettings();
var settings = new VerifySettings(classLevelSettings);
settings.UseExtension("xml");
await Verify(
await Verifier.Verify(
target: @"<note>
<to>Joe</to>
<from>Kim</from>
Expand All @@ -110,41 +138,82 @@ public class ExtensionSample :
settings: settings);
}

[Fact]
public async Task InheritedFromClass()
[Test]
public async Task SharedClassLevelSettings()
{
await Verify(
await Verifier.Verify(
target: @"{
""fruit"": ""Apple"",
""size"": ""Large"",
""color"": ""Red""
}",
settings: classLevelSettings);
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ExtensionSample.cs#L1-L42' title='File snippet `ExtensionSample.cs` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.cs' title='Navigate to start of snippet `ExtensionSample.cs`'>anchor</a></sup>
<a id='snippet-ExtensionSample.cs-1'/></a>
```cs
using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;

public class ExtensionSample :
VerifyBase
{
VerifySettings classLevelSettings;

public ExtensionSample(ITestOutputHelper output) :
base(output)
{
classLevelSettings = new VerifySettings();
classLevelSettings.UseExtension("json");
}

[Fact]
public Task AtMethod()
{
var settings = new VerifySettings(classLevelSettings);
settings.UseExtension("xml");
return Verify(
target: @"<note>
<to>Joe</to>
<from>Kim</from>
<heading>Reminder</heading>
</note>",
settings: settings);
}

[Fact]
public Task SharedClassLevelSettings()
{
return Verify(
target: @"{
""fruit"": ""Apple"",
""size"": ""Large"",
""color"": ""Red""
}",
settings: classLevelSettings);
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.cs#L1-L44' title='File snippet `ExtensionSample.cs` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.cs' title='Navigate to start of snippet `ExtensionSample.cs`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.cs#L1-L44' title='File snippet `ExtensionSample.cs` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.cs-1' title='Navigate to start of snippet `ExtensionSample.cs`'>anchor</a></sup>
<!-- endsnippet -->

Result in two files:

<!-- snippet: ExtensionSample.InheritedFromClass.verified.json -->
<a id='snippet-ExtensionSample.InheritedFromClass.verified.json'/></a>
<!-- snippet: ExtensionSample.SharedClassLevelSettings.verified.json -->
<a id='snippet-ExtensionSample.SharedClassLevelSettings.verified.json'/></a>
```json
{
"fruit": "Apple",
"size": "Large",
"color": "Red"
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.InheritedFromClass.verified.json#L1-L5' title='File snippet `ExtensionSample.InheritedFromClass.verified.json` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.InheritedFromClass.verified.json' title='Navigate to start of snippet `ExtensionSample.InheritedFromClass.verified.json`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.SharedClassLevelSettings.verified.json#L1-L5' title='File snippet `ExtensionSample.SharedClassLevelSettings.verified.json` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.SharedClassLevelSettings.verified.json' title='Navigate to start of snippet `ExtensionSample.SharedClassLevelSettings.verified.json`'>anchor</a></sup>
<!-- endsnippet -->

<!-- snippet: ExtensionSample.AtMethod.verified.xml -->
Expand All @@ -156,5 +225,14 @@ Result in two files:
<heading>Reminder</heading>
</note>
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.AtMethod.verified.xml#L1-L5' title='File snippet `ExtensionSample.AtMethod.verified.xml` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.AtMethod.verified.xml' title='Navigate to start of snippet `ExtensionSample.AtMethod.verified.xml`'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ExtensionSample.AtMethod.verified.xml#L1-L5' title='File snippet `ExtensionSample.AtMethod.verified.xml` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.AtMethod.verified.xml' title='Navigate to start of snippet `ExtensionSample.AtMethod.verified.xml`'>anchor</a></sup>
<a id='snippet-ExtensionSample.AtMethod.verified.xml-1'/></a>
```xml
<note>
<to>Joe</to>
<from>Kim</from>
<heading>Reminder</heading>
</note>
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.AtMethod.verified.xml#L1-L5' title='File snippet `ExtensionSample.AtMethod.verified.xml` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.AtMethod.verified.xml-1' title='Navigate to start of snippet `ExtensionSample.AtMethod.verified.xml`'>anchor</a></sup>
<!-- endsnippet -->
84 changes: 73 additions & 11 deletions docs/scrubbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,56 @@ Usage:
<a id='snippet-scrubberssample.cs'/></a>
```cs
using System.Threading.Tasks;
using NUnit.Framework;
using Verify;
using VerifyNUnit;

[TestFixture]
public class ScrubbersSample
{
VerifySettings classLevelSettings;

public ScrubbersSample()
{
classLevelSettings = new VerifySettings();
classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
}

[Test]
public Task Simple()
{
var settings = new VerifySettings(classLevelSettings);
settings.AddScrubber(s => s.Replace("Two", "B"));
return Verifier.Verify("One Two Three", settings);
}

[Test]
public Task AfterJson()
{
var target = new ToBeScrubbed
{
RowVersion = "0x00000000000007D3"
};

var settings = new VerifySettings(classLevelSettings);
settings.AddScrubber(s => s.Replace("0x00000000000007D3", "TheRowVersion"));
return Verifier.Verify(target, settings);
}

public static class GlobalSetup
{
[OneTimeSetUp]
public static void Setup()
{
Global.AddScrubber(s => s.Replace("One", "A"));
}
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubbersSample.cs#L1-L46' title='File snippet `scrubberssample.cs` was extracted from'>snippet source</a> | <a href='#snippet-scrubberssample.cs' title='Navigate to start of snippet `scrubberssample.cs`'>anchor</a></sup>
<a id='snippet-scrubberssample.cs-1'/></a>
```cs
using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
Expand All @@ -35,7 +85,14 @@ using Xunit.Abstractions;
public class ScrubbersSample :
VerifyBase
{
private VerifySettings classLevelSettings;
VerifySettings classLevelSettings;

public ScrubbersSample(ITestOutputHelper output) :
base(output)
{
classLevelSettings = new VerifySettings();
classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
}

[Fact]
public Task Simple()
Expand All @@ -58,13 +115,6 @@ public class ScrubbersSample :
return Verify(target, settings);
}

public ScrubbersSample(ITestOutputHelper output) :
base(output)
{
classLevelSettings = new VerifySettings();
classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
}

[GlobalSetUp]
public static class GlobalSetup
{
Expand All @@ -75,7 +125,7 @@ public class ScrubbersSample :
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L48' title='File snippet `scrubberssample.cs` was extracted from'>snippet source</a> | <a href='#snippet-scrubberssample.cs' title='Navigate to start of snippet `scrubberssample.cs`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L1-L48' title='File snippet `scrubberssample.cs` was extracted from'>snippet source</a> | <a href='#snippet-scrubberssample.cs-1' title='Navigate to start of snippet `scrubberssample.cs`'>anchor</a></sup>
<!-- endsnippet -->

Results:
Expand All @@ -85,7 +135,12 @@ Results:
```txt
A B C
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.Simple.verified.txt#L1-L1' title='File snippet `ScrubbersSample.Simple.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-ScrubbersSample.Simple.verified.txt' title='Navigate to start of snippet `ScrubbersSample.Simple.verified.txt`'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubbersSample.Simple.verified.txt#L1-L1' title='File snippet `ScrubbersSample.Simple.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-ScrubbersSample.Simple.verified.txt' title='Navigate to start of snippet `ScrubbersSample.Simple.verified.txt`'>anchor</a></sup>
<a id='snippet-ScrubbersSample.Simple.verified.txt-1'/></a>
```txt
A B C
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.Simple.verified.txt#L1-L1' title='File snippet `ScrubbersSample.Simple.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-ScrubbersSample.Simple.verified.txt-1' title='Navigate to start of snippet `ScrubbersSample.Simple.verified.txt`'>anchor</a></sup>
<!-- endsnippet -->

<!-- snippet: ScrubbersSample.AfterJson.verified.txt -->
Expand All @@ -95,6 +150,13 @@ A B C
RowVersion: 'TheRowVersion'
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.AfterJson.verified.txt#L1-L3' title='File snippet `ScrubbersSample.AfterJson.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-ScrubbersSample.AfterJson.verified.txt' title='Navigate to start of snippet `ScrubbersSample.AfterJson.verified.txt`'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Scrubbers/ScrubbersSample.AfterJson.verified.txt#L1-L3' title='File snippet `ScrubbersSample.AfterJson.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-ScrubbersSample.AfterJson.verified.txt' title='Navigate to start of snippet `ScrubbersSample.AfterJson.verified.txt`'>anchor</a></sup>
<a id='snippet-ScrubbersSample.AfterJson.verified.txt-1'/></a>
```txt
{
RowVersion: 'TheRowVersion'
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.AfterJson.verified.txt#L1-L3' title='File snippet `ScrubbersSample.AfterJson.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-ScrubbersSample.AfterJson.verified.txt-1' title='Navigate to start of snippet `ScrubbersSample.AfterJson.verified.txt`'>anchor</a></sup>
<!-- endsnippet -->

Loading

0 comments on commit a2194e4

Please sign in to comment.