Skip to content

Commit

Permalink
Make xunit api static (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Jun 9, 2020
1 parent 2643568 commit e6be73b
Show file tree
Hide file tree
Showing 123 changed files with 686 additions and 1,514 deletions.
4 changes: 2 additions & 2 deletions docs/anonymous-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public async Task Anon()
FamilyName = "Aguirre"
};

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


Expand Down
2 changes: 1 addition & 1 deletion docs/build-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ if (BuildServerDetector.Detected)
});
}
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L67-L80' title='File snippet `derivetestdirectory` was extracted from'>snippet source</a> | <a href='#snippet-derivetestdirectory' title='Navigate to start of snippet `derivetestdirectory`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L65-L78' title='File snippet `derivetestdirectory` was extracted from'>snippet source</a> | <a href='#snippet-derivetestdirectory' title='Navigate to start of snippet `derivetestdirectory`'>anchor</a></sup>
<!-- endsnippet -->
6 changes: 3 additions & 3 deletions docs/clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The clipboard behavior can be disable using the following:
var settings = new VerifySettings();
settings.DisableClipboard();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L38-L43' title='File snippet `disableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboard' title='Navigate to start of snippet `disableclipboard`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L36-L41' title='File snippet `disableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboard' title='Navigate to start of snippet `disableclipboard`'>anchor</a></sup>
<!-- endsnippet -->


Expand All @@ -77,7 +77,7 @@ settings.DisableClipboard();
```cs
SharedVerifySettings.DisableClipboard();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L58-L62' title='File snippet `disableclipboardglobal` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboardglobal' title='Navigate to start of snippet `disableclipboardglobal`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L56-L60' title='File snippet `disableclipboardglobal` was extracted from'>snippet source</a> | <a href='#snippet-disableclipboardglobal' title='Navigate to start of snippet `disableclipboardglobal`'>anchor</a></sup>
<!-- endsnippet -->

If clipboard is disabled for all tests, it can be re-enabled at the test level:
Expand All @@ -88,7 +88,7 @@ If clipboard is disabled for all tests, it can be re-enabled at the test level:
var settings = new VerifySettings();
settings.EnableClipboard();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L48-L53' title='File snippet `enableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-enableclipboard' title='Navigate to start of snippet `enableclipboard`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L46-L51' title='File snippet `enableclipboard` was extracted from'>snippet source</a> | <a href='#snippet-enableclipboard' title='Navigate to start of snippet `enableclipboard`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down
10 changes: 5 additions & 5 deletions docs/comparer.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static Digest HashImage(Stream stream)
return ImagePhash.ComputeDigest(bitmap.ToLuminanceImage());
}
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L39-L64' title='File snippet `imagecomparer` was extracted from'>snippet source</a> | <a href='#snippet-imagecomparer' title='Navigate to start of snippet `imagecomparer`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L32-L57' title='File snippet `imagecomparer` was extracted from'>snippet source</a> | <a href='#snippet-imagecomparer' title='Navigate to start of snippet `imagecomparer`'>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 @@ -58,9 +58,9 @@ The returned `CompareResult.NotEqual` takes an optional message that will be ren
var settings = new VerifySettings();
settings.UseComparer(CompareImages);
settings.UseExtension("png");
await Verify("TheImage.png", settings);
await Verifier.Verify("TheImage.png", settings);
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L21-L26' title='File snippet `instancecomparer` was extracted from'>snippet source</a> | <a href='#snippet-instancecomparer' title='Navigate to start of snippet `instancecomparer`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L14-L19' title='File snippet `instancecomparer` was extracted from'>snippet source</a> | <a href='#snippet-instancecomparer' title='Navigate to start of snippet `instancecomparer`'>anchor</a></sup>
<!-- endsnippet -->


Expand All @@ -72,9 +72,9 @@ await Verify("TheImage.png", settings);
SharedVerifySettings.RegisterComparer(
extension: "png",
compare: CompareImages);
await VerifyFile("TheImage.png");
await Verifier.VerifyFile("TheImage.png");
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L31-L36' title='File snippet `staticcomparer` was extracted from'>snippet source</a> | <a href='#snippet-staticcomparer' title='Navigate to start of snippet `staticcomparer`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L24-L29' title='File snippet `staticcomparer` was extracted from'>snippet source</a> | <a href='#snippet-staticcomparer' title='Navigate to start of snippet `staticcomparer`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down
14 changes: 7 additions & 7 deletions docs/converter.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ SharedVerifySettings.RegisterFileConverter<Image>(
streams);
});
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L18-L47' title='File snippet `registerfileconvertertype` was extracted from'>snippet source</a> | <a href='#snippet-registerfileconvertertype' title='Navigate to start of snippet `registerfileconvertertype`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L16-L45' title='File snippet `registerfileconvertertype` was extracted from'>snippet source</a> | <a href='#snippet-registerfileconvertertype' title='Navigate to start of snippet `registerfileconvertertype`'>anchor</a></sup>
<!-- endsnippet -->

<!-- snippet: FileConverterTypeVerify -->
<a id='snippet-fileconvertertypeverify'/></a>
```cs
await using var stream = File.OpenRead("sample.tif");
await Verify(Image.FromStream(stream));
await Verifier.Verify(Image.FromStream(stream));
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L48-L51' title='File snippet `fileconvertertypeverify` was extracted from'>snippet source</a> | <a href='#snippet-fileconvertertypeverify' title='Navigate to start of snippet `fileconvertertypeverify`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L46-L49' title='File snippet `fileconvertertypeverify` was extracted from'>snippet source</a> | <a href='#snippet-fileconvertertypeverify' title='Navigate to start of snippet `fileconvertertypeverify`'>anchor</a></sup>
<!-- endsnippet -->

Note that this sample also uses the optional `canConvert` to ensure that only `Image`s that are tiffs are converted.
Expand All @@ -96,7 +96,7 @@ Note that this sample also uses the optional `canConvert` to ensure that only `I
```cs
canConvert: target => Equals(target.RawFormat, ImageFormat.Tiff),
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L21-L23' title='File snippet `convertercanconvert` was extracted from'>snippet source</a> | <a href='#snippet-convertercanconvert' title='Navigate to start of snippet `convertercanconvert`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L19-L21' title='File snippet `convertercanconvert` was extracted from'>snippet source</a> | <a href='#snippet-convertercanconvert' title='Navigate to start of snippet `convertercanconvert`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down Expand Up @@ -134,15 +134,15 @@ SharedVerifySettings.RegisterFileConverter(
streams);
});
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L57-L85' title='File snippet `registerfileconverterextension` was extracted from'>snippet source</a> | <a href='#snippet-registerfileconverterextension' title='Navigate to start of snippet `registerfileconverterextension`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L55-L83' title='File snippet `registerfileconverterextension` was extracted from'>snippet source</a> | <a href='#snippet-registerfileconverterextension' title='Navigate to start of snippet `registerfileconverterextension`'>anchor</a></sup>
<!-- endsnippet -->

<!-- snippet: FileConverterExtensionVerify -->
<a id='snippet-fileconverterextensionverify'/></a>
```cs
await VerifyFile("sample.tif");
await Verifier.VerifyFile("sample.tif");
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L86-L88' title='File snippet `fileconverterextensionverify` was extracted from'>snippet source</a> | <a href='#snippet-fileconverterextensionverify' title='Navigate to start of snippet `fileconverterextensionverify`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L84-L86' title='File snippet `fileconverterextensionverify` was extracted from'>snippet source</a> | <a href='#snippet-fileconverterextensionverify' title='Navigate to start of snippet `fileconverterextensionverify`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down
6 changes: 3 additions & 3 deletions docs/named-tuples.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ static (bool Member1, string Member2, string Member3) MethodWithNamedTuple()
return (true, "A", "B");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L343-L350' title='File snippet `methodwithnamedtuple` was extracted from'>snippet source</a> | <a href='#snippet-methodwithnamedtuple' title='Navigate to start of snippet `methodwithnamedtuple`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L341-L348' title='File snippet `methodwithnamedtuple` was extracted from'>snippet source</a> | <a href='#snippet-methodwithnamedtuple' title='Navigate to start of snippet `methodwithnamedtuple`'>anchor</a></sup>
<!-- endsnippet -->

Can be verified:

<!-- snippet: VerifyTuple -->
<a id='snippet-verifytuple'/></a>
```cs
await Verify(() => MethodWithNamedTuple());
await Verifier.Verify(() => MethodWithNamedTuple());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L336-L340' title='File snippet `verifytuple` was extracted from'>snippet source</a> | <a href='#snippet-verifytuple' title='Navigate to start of snippet `verifytuple`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L334-L338' title='File snippet `verifytuple` was extracted from'>snippet source</a> | <a href='#snippet-verifytuple' title='Navigate to start of snippet `verifytuple`'>anchor</a></sup>
<!-- endsnippet -->

Resulting in:
Expand Down
31 changes: 11 additions & 20 deletions docs/naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,40 +30,34 @@ UniqueFor allows for one or more delimiters to be added to the file name.
<!-- snippet: UniqueForSampleXunit -->
<a id='snippet-uniqueforsamplexunit'/></a>
```cs
public class UniqueForSample :
VerifyBase
public class UniqueForSample
{
[Fact]
public Task Runtime()
{
var settings = new VerifySettings();
settings.UniqueForRuntime();
return Verify("value", settings);
return Verifier.Verify("value", settings);
}

[Fact]
public Task RuntimeAndVersion()
{
var settings = new VerifySettings();
settings.UniqueForRuntimeAndVersion();
return Verify("value", settings);
return Verifier.Verify("value", settings);
}

[Fact]
public Task AssemblyConfiguration()
{
var settings = new VerifySettings();
settings.UniqueForAssemblyConfiguration();
return Verify("value", settings);
}

public UniqueForSample(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify("value", settings);
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L7-L40' title='File snippet `uniqueforsamplexunit` was extracted from'>snippet source</a> | <a href='#snippet-uniqueforsamplexunit' title='Navigate to start of snippet `uniqueforsamplexunit`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L6-L33' title='File snippet `uniqueforsamplexunit` was extracted from'>snippet source</a> | <a href='#snippet-uniqueforsamplexunit' title='Navigate to start of snippet `uniqueforsamplexunit`'>anchor</a></sup>
<!-- endsnippet -->


Expand Down Expand Up @@ -271,15 +265,12 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;

public class ExtensionSample :
VerifyBase
public class ExtensionSample
{
VerifySettings classLevelSettings;

public ExtensionSample(ITestOutputHelper output) :
base(output)
public ExtensionSample()
{
classLevelSettings = new VerifySettings();
classLevelSettings.UseExtension("json");
Expand All @@ -290,7 +281,7 @@ public class ExtensionSample :
{
var settings = new VerifySettings(classLevelSettings);
settings.UseExtension("xml");
return Verify(
return Verifier.Verify(
target: @"<note>
<to>Joe</to>
<from>Kim</from>
Expand All @@ -302,7 +293,7 @@ public class ExtensionSample :
[Fact]
public Task SharedClassLevelSettings()
{
return Verify(
return Verifier.Verify(
target: @"{
""fruit"": ""Apple"",
""size"": ""Large"",
Expand All @@ -312,7 +303,7 @@ public class ExtensionSample :
}
}
```
<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-2' title='Navigate to start of snippet `ExtensionSample.cs`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ExtensionSample.cs#L1-L41' title='File snippet `ExtensionSample.cs` was extracted from'>snippet source</a> | <a href='#snippet-ExtensionSample.cs-2' title='Navigate to start of snippet `ExtensionSample.cs`'>anchor</a></sup>
<!-- endsnippet -->

Result in two files:
Expand Down Expand Up @@ -352,5 +343,5 @@ To access the current Namer `Runtime` or `RuntimeAndVersion` strings use:
Debug.WriteLine(Namer.Runtime);
Debug.WriteLine(Namer.RuntimeAndVersion);
```
<sup><a href='/src/Verify.Tests/NamerTests.cs#L52-L55' title='File snippet `accessnamerruntimeandversion` was extracted from'>snippet source</a> | <a href='#snippet-accessnamerruntimeandversion' title='Navigate to start of snippet `accessnamerruntimeandversion`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/NamerTests.cs#L50-L53' title='File snippet `accessnamerruntimeandversion` was extracted from'>snippet source</a> | <a href='#snippet-accessnamerruntimeandversion' title='Navigate to start of snippet `accessnamerruntimeandversion`'>anchor</a></sup>
<!-- endsnippet -->
27 changes: 13 additions & 14 deletions docs/parameterised.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ A test with two parameters `param1` + `param2`, and called twice with the values
[InlineData("Value2")]
public Task InlineDataUsage(string arg)
{
return Verify(arg);
var settings = new VerifySettings();
settings.UseParameters(arg);
return Verifier.Verify(arg, settings);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L10-L18' title='File snippet `xunitinlinedata` was extracted from'>snippet source</a> | <a href='#snippet-xunitinlinedata' title='Navigate to start of snippet `xunitinlinedata`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L8-L18' title='File snippet `xunitinlinedata` was extracted from'>snippet source</a> | <a href='#snippet-xunitinlinedata' title='Navigate to start of snippet `xunitinlinedata`'>anchor</a></sup>
<!-- endsnippet -->


Expand All @@ -49,7 +51,9 @@ public Task InlineDataUsage(string arg)
[MemberData(nameof(GetData))]
public Task MemberDataUsage(string arg)
{
return Verify(arg);
var settings = new VerifySettings();
settings.UseParameters(arg);
return Verifier.Verify(arg, settings);
}

public static IEnumerable<object[]> GetData()
Expand All @@ -58,7 +62,7 @@ public static IEnumerable<object[]> GetData()
yield return new object[] {"Value2"};
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L20-L33' title='File snippet `xunitmemberdata` was extracted from'>snippet source</a> | <a href='#snippet-xunitmemberdata' title='Navigate to start of snippet `xunitmemberdata`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ParametersSample.cs#L20-L35' title='File snippet `xunitmemberdata` was extracted from'>snippet source</a> | <a href='#snippet-xunitmemberdata' title='Navigate to start of snippet `xunitmemberdata`'>anchor</a></sup>
<!-- endsnippet -->


Expand All @@ -69,8 +73,7 @@ xUnit only exposes parameter information when the types certain types. For unkno
<!-- snippet: xunitComplexMemberData -->
<a id='snippet-xunitcomplexmemberdata'/></a>
```cs
public class ComplexParametersSample :
VerifyBase
public class ComplexParametersSample
{
static ComplexParametersSample()
{
Expand All @@ -82,8 +85,9 @@ public class ComplexParametersSample :
[MemberData(nameof(GetComplexMemberData))]
public Task ComplexMemberData(ComplexData arg)
{
UseParameters(arg);
return Verify(arg);
var settings = new VerifySettings();
settings.UseParameters(arg);
return Verifier.Verify(arg, settings);
}

public static IEnumerable<object[]> GetComplexMemberData()
Expand All @@ -102,14 +106,9 @@ public class ComplexParametersSample :
{
public string Value { get; set; } = null!;
}

public ComplexParametersSample(ITestOutputHelper output) :
base(output)
{
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L8-L48' title='File snippet `xunitcomplexmemberdata` was extracted from'>snippet source</a> | <a href='#snippet-xunitcomplexmemberdata' title='Navigate to start of snippet `xunitcomplexmemberdata`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L7-L42' title='File snippet `xunitcomplexmemberdata` was extracted from'>snippet source</a> | <a href='#snippet-xunitcomplexmemberdata' title='Navigate to start of snippet `xunitcomplexmemberdata`'>anchor</a></sup>
<!-- endsnippet -->

`SharedVerifySettings.NameForParameter` is required since the parameter type has no `ToString()` override that can be used for deriving the name of the `.verified.` file.
Expand Down
Loading

0 comments on commit e6be73b

Please sign in to comment.