This commit is contained in:
Simon Cropp 2020-06-09 23:53:45 +10:00 коммит произвёл GitHub
Родитель 26435686de
Коммит e6be73bddc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
123 изменённых файлов: 686 добавлений и 1514 удалений

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

@ -29,7 +29,7 @@ public async Task Anon()
FamilyName = "Aguirre"
};
await Verify(
await Verifier.Verify(
new
{
person1,
@ -37,7 +37,7 @@ public async Task Anon()
});
}
```
<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 -->

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

@ -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 -->

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

@ -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 -->
@ -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:
@ -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 -->

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

@ -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.
@ -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 -->
@ -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 -->

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

@ -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.
@ -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 -->
@ -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 -->

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

@ -21,7 +21,7 @@ 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:
@ -29,9 +29,9 @@ 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:

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

@ -30,15 +30,14 @@ 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]
@ -46,7 +45,7 @@ public class UniqueForSample :
{
var settings = new VerifySettings();
settings.UniqueForRuntimeAndVersion();
return Verify("value", settings);
return Verifier.Verify("value", settings);
}
[Fact]
@ -54,16 +53,11 @@ public class UniqueForSample :
{
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 -->
@ -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");
@ -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>
@ -302,7 +293,7 @@ public class ExtensionSample :
[Fact]
public Task SharedClassLevelSettings()
{
return Verify(
return Verifier.Verify(
target: @"{
""fruit"": ""Apple"",
""size"": ""Large"",
@ -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:
@ -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 -->

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

@ -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 -->
@ -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()
@ -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 -->
@ -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()
{
@ -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()
@ -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.

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

@ -30,7 +30,7 @@ For example remove lines containing `text`:
```cs
verifySettings.ScrubLines(line => line.Contains("text"));
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L248-L252' title='File snippet `scrublines` was extracted from'>snippet source</a> | <a href='#snippet-scrublines' title='Navigate to start of snippet `scrublines`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L246-L250' title='File snippet `scrublines` was extracted from'>snippet source</a> | <a href='#snippet-scrublines' title='Navigate to start of snippet `scrublines`'>anchor</a></sup>
<!-- endsnippet -->
@ -45,7 +45,7 @@ For example remove lines containing `text1` or `text2`
```cs
verifySettings.ScrubLinesContaining("text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L254-L258' title='File snippet `scrublinescontaining` was extracted from'>snippet source</a> | <a href='#snippet-scrublinescontaining' title='Navigate to start of snippet `scrublinescontaining`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L252-L256' title='File snippet `scrublinescontaining` was extracted from'>snippet source</a> | <a href='#snippet-scrublinescontaining' title='Navigate to start of snippet `scrublinescontaining`'>anchor</a></sup>
<!-- endsnippet -->
Case insensitive by default (StringComparison.OrdinalIgnoreCase).
@ -57,7 +57,7 @@ Case insensitive by default (StringComparison.OrdinalIgnoreCase).
```cs
verifySettings.ScrubLinesContaining(StringComparison.Ordinal, "text1", "text2");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L260-L264' title='File snippet `scrublinescontainingordinal` was extracted from'>snippet source</a> | <a href='#snippet-scrublinescontainingordinal' title='Navigate to start of snippet `scrublinescontainingordinal`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L258-L262' title='File snippet `scrublinescontainingordinal` was extracted from'>snippet source</a> | <a href='#snippet-scrublinescontainingordinal' title='Navigate to start of snippet `scrublinescontainingordinal`'>anchor</a></sup>
<!-- endsnippet -->
@ -72,7 +72,7 @@ For example converts lines to upper case:
```cs
verifySettings.ScrubLinesWithReplace(line => line.ToUpper());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L266-L270' title='File snippet `scrublineswithreplace` was extracted from'>snippet source</a> | <a href='#snippet-scrublineswithreplace' title='Navigate to start of snippet `scrublineswithreplace`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L264-L268' title='File snippet `scrublineswithreplace` was extracted from'>snippet source</a> | <a href='#snippet-scrublineswithreplace' title='Navigate to start of snippet `scrublineswithreplace`'>anchor</a></sup>
<!-- endsnippet -->
@ -85,7 +85,7 @@ Replaces `Environment.MachineName` with `TheMachineName`.
```cs
verifySettings.ScrubMachineName();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L272-L276' title='File snippet `scrubmachinename` was extracted from'>snippet source</a> | <a href='#snippet-scrubmachinename' title='Navigate to start of snippet `scrubmachinename`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L270-L274' title='File snippet `scrubmachinename` was extracted from'>snippet source</a> | <a href='#snippet-scrubmachinename' title='Navigate to start of snippet `scrubmachinename`'>anchor</a></sup>
<!-- endsnippet -->
@ -102,13 +102,8 @@ Adds a scrubber with full control over the text via a `Func`
<!-- snippet: ScrubbersSampleXunit -->
<a id='snippet-scrubberssamplexunit'/></a>
```cs
public class ScrubbersSample :
VerifyBase
public class ScrubbersSample
{
public ScrubbersSample(ITestOutputHelper output) :
base(output)
{
}
[Fact]
public Task Lines()
{
@ -125,7 +120,7 @@ public class ScrubbersSample :
settings.ScrubLines(removeLine: line => line.Contains("J"));
settings.ScrubLinesContaining("b", "D");
settings.ScrubLinesContaining(StringComparison.Ordinal, "H");
return Verify(
return Verifier.Verify(
settings: settings,
target: @"
LineA
@ -150,11 +145,11 @@ LineJ
var settings = new VerifySettings();
settings.AddScrubber(
input => input.Replace("0x00000000000007D3", "TheRowVersion"));
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L8-L60' title='File snippet `scrubberssamplexunit` was extracted from'>snippet source</a> | <a href='#snippet-scrubberssamplexunit' title='Navigate to start of snippet `scrubberssamplexunit`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubbersSample.cs#L7-L54' title='File snippet `scrubberssamplexunit` was extracted from'>snippet source</a> | <a href='#snippet-scrubberssamplexunit' title='Navigate to start of snippet `scrubberssamplexunit`'>anchor</a></sup>
<!-- endsnippet -->
@ -315,13 +310,11 @@ Global scrubbers should be defined only once at appdomain startup. In this examp
<!-- snippet: ScrubberLevelsSampleXunit -->
<a id='snippet-scrubberlevelssamplexunit'/></a>
```cs
public class ScrubberLevelsSample :
VerifyBase
public class ScrubberLevelsSample
{
VerifySettings classLevelSettings;
public ScrubberLevelsSample(ITestOutputHelper output) :
base(output)
public ScrubberLevelsSample()
{
classLevelSettings = new VerifySettings();
classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
@ -332,7 +325,7 @@ public class ScrubberLevelsSample :
{
var settings = new VerifySettings(classLevelSettings);
settings.AddScrubber(s => s.Replace("Two", "B"));
return Verify("One Two Three", settings);
return Verifier.Verify("One Two Three", settings);
}
static ScrubberLevelsSample()
@ -342,7 +335,6 @@ public class ScrubberLevelsSample :
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Scrubbers/ScrubberLevelsSample.cs#L7-L34' title='File snippet `scrubberlevelssamplexunit` was extracted from'>snippet source</a> | <a href='#snippet-scrubberlevelssamplexunit' title='Navigate to start of snippet `scrubberlevelssamplexunit`'>anchor</a></sup>
<!-- endsnippet -->

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

@ -75,7 +75,7 @@ To disable this behavior globally use:
```cs
SharedVerifySettings.ModifySerialization(_ => _.DontIgnoreEmptyCollections());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L193-L195' title='File snippet `dontignoreemptycollections` was extracted from'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Navigate to start of snippet `dontignoreemptycollections`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L191-L193' title='File snippet `dontignoreemptycollections` was extracted from'>snippet source</a> | <a href='#snippet-dontignoreemptycollections' title='Navigate to start of snippet `dontignoreemptycollections`'>anchor</a></sup>
<!-- endsnippet -->
@ -95,9 +95,9 @@ var target = new GuidTarget
OtherGuid = Guid.NewGuid(),
};
await Verify(target);
await Verifier.Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L355-L368' title='File snippet `guid` was extracted from'>snippet source</a> | <a href='#snippet-guid' title='Navigate to start of snippet `guid`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L353-L366' title='File snippet `guid` was extracted from'>snippet source</a> | <a href='#snippet-guid' title='Navigate to start of snippet `guid`'>anchor</a></sup>
<!-- endsnippet -->
Results in the following:
@ -122,7 +122,7 @@ To disable this behavior globally use:
```cs
SharedVerifySettings.ModifySerialization(_ => _.DontScrubGuids());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L200-L202' title='File snippet `dontscrubguids` was extracted from'>snippet source</a> | <a href='#snippet-dontscrubguids' title='Navigate to start of snippet `dontscrubguids`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L198-L200' title='File snippet `dontscrubguids` was extracted from'>snippet source</a> | <a href='#snippet-dontscrubguids' title='Navigate to start of snippet `dontscrubguids`'>anchor</a></sup>
<!-- endsnippet -->
Strings containing inline Guids can also be scrubbed. To enable this behavior, use:
@ -132,7 +132,7 @@ Strings containing inline Guids can also be scrubbed. To enable this behavior, u
```cs
SharedVerifySettings.ModifySerialization(_ => _.ScrubInlineGuids());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L207-L209' title='File snippet `scrubinlineguids` was extracted from'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Navigate to start of snippet `scrubinlineguids`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L205-L207' title='File snippet `scrubinlineguids` was extracted from'>snippet source</a> | <a href='#snippet-scrubinlineguids' title='Navigate to start of snippet `scrubinlineguids`'>anchor</a></sup>
<!-- endsnippet -->
@ -155,9 +155,9 @@ var target = new DateTimeTarget
DateTimeOffsetString = dateTimeOffset.ToString("F"),
};
await Verify(target);
await Verifier.Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L26-L42' title='File snippet `date` was extracted from'>snippet source</a> | <a href='#snippet-date' title='Navigate to start of snippet `date`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L24-L40' title='File snippet `date` was extracted from'>snippet source</a> | <a href='#snippet-date' title='Navigate to start of snippet `date`'>anchor</a></sup>
<!-- endsnippet -->
Results in the following:
@ -184,7 +184,7 @@ To disable this behavior globally use:
```cs
SharedVerifySettings.ModifySerialization(_ => _.DontScrubDateTimes());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L214-L216' title='File snippet `dontscrubdatetimes` was extracted from'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Navigate to start of snippet `dontscrubdatetimes`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L212-L214' title='File snippet `dontscrubdatetimes` was extracted from'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Navigate to start of snippet `dontscrubdatetimes`'>anchor</a></sup>
<!-- endsnippet -->
@ -199,7 +199,7 @@ To disable this behavior globally use:
```cs
SharedVerifySettings.ModifySerialization(_ => _.DontIgnoreFalse());
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L221-L223' title='File snippet `dontignorefalse` was extracted from'>snippet source</a> | <a href='#snippet-dontignorefalse' title='Navigate to start of snippet `dontignorefalse`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L219-L221' title='File snippet `dontignorefalse` was extracted from'>snippet source</a> | <a href='#snippet-dontignorefalse' title='Navigate to start of snippet `dontignorefalse`'>anchor</a></sup>
<!-- endsnippet -->
@ -251,7 +251,7 @@ settings.AddExtraSettings(_ =>
_.TypeNameHandling = TypeNameHandling.All;
});
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L105-L114' title='File snippet `extrasettings` was extracted from'>snippet source</a> | <a href='#snippet-extrasettings' title='Navigate to start of snippet `extrasettings`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L103-L112' title='File snippet `extrasettings` was extracted from'>snippet source</a> | <a href='#snippet-extrasettings' title='Navigate to start of snippet `extrasettings`'>anchor</a></sup>
<!-- endsnippet -->
@ -272,7 +272,7 @@ settings.ModifySerialization(
settings.AddExtraSettings(
_ => { _.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat; });
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L810-L824' title='File snippet `scopedserializer` was extracted from'>snippet source</a> | <a href='#snippet-scopedserializer' title='Navigate to start of snippet `scopedserializer`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L808-L822' title='File snippet `scopedserializer` was extracted from'>snippet source</a> | <a href='#snippet-scopedserializer' title='Navigate to start of snippet `scopedserializer`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -311,9 +311,9 @@ var target = new IgnoreTypeTarget
Property = "Value"
}
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L563-L581' title='File snippet `addignoretype` was extracted from'>snippet source</a> | <a href='#snippet-addignoretype' title='Navigate to start of snippet `addignoretype`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L561-L579' title='File snippet `addignoretype` was extracted from'>snippet source</a> | <a href='#snippet-addignoretype' title='Navigate to start of snippet `addignoretype`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -353,9 +353,9 @@ var target = new IgnoreInstanceTarget
Property = "Include"
}
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L527-L546' title='File snippet `addignoreinstance` was extracted from'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Navigate to start of snippet `addignoreinstance`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L525-L544' title='File snippet `addignoreinstance` was extracted from'>snippet source</a> | <a href='#snippet-addignoreinstance' title='Navigate to start of snippet `addignoreinstance`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -394,10 +394,10 @@ public Task WithObsoleteProp()
ObsoleteProperty = "value1",
OtherProperty = "value2"
};
return Verify(target);
return Verifier.Verify(target);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L772-L791' title='File snippet `withobsoleteprop` was extracted from'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Navigate to start of snippet `withobsoleteprop`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L770-L789' title='File snippet `withobsoleteprop` was extracted from'>snippet source</a> | <a href='#snippet-withobsoleteprop' title='Navigate to start of snippet `withobsoleteprop`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -430,10 +430,10 @@ public Task WithObsoletePropIncluded()
};
var settings = new VerifySettings();
settings.ModifySerialization(_ => { _.IncludeObsoletes(); });
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L756-L771' title='File snippet `withobsoletepropincluded` was extracted from'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Navigate to start of snippet `withobsoletepropincluded`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L754-L769' title='File snippet `withobsoletepropincluded` was extracted from'>snippet source</a> | <a href='#snippet-withobsoletepropincluded' title='Navigate to start of snippet `withobsoletepropincluded`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -472,9 +472,9 @@ var target = new IgnoreExplicitTarget
Field = "Value",
Property = "Value"
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L603-L622' title='File snippet `ignorememberbyexpression` was extracted from'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Navigate to start of snippet `ignorememberbyexpression`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L601-L620' title='File snippet `ignorememberbyexpression` was extracted from'>snippet source</a> | <a href='#snippet-ignorememberbyexpression' title='Navigate to start of snippet `ignorememberbyexpression`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -515,9 +515,9 @@ var target = new IgnoreExplicitTarget
Property = "Value",
PropertyByName = "Value"
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L628-L650' title='File snippet `ignorememberbyname` was extracted from'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Navigate to start of snippet `ignorememberbyname`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L626-L648' title='File snippet `ignorememberbyname` was extracted from'>snippet source</a> | <a href='#snippet-ignorememberbyname' title='Navigate to start of snippet `ignorememberbyname`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -550,9 +550,9 @@ var settings = new VerifySettings();
settings.ModifySerialization(_ => _.IgnoreMembersThatThrow<CustomException>());
var target = new WithCustomException();
await Verify(target, settings);
await Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L666-L674' title='File snippet `ignoremembersthatthrow` was extracted from'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Navigate to start of snippet `ignoremembersthatthrow`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L664-L672' title='File snippet `ignoremembersthatthrow` was extracted from'>snippet source</a> | <a href='#snippet-ignoremembersthatthrow' title='Navigate to start of snippet `ignoremembersthatthrow`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -575,9 +575,9 @@ settings.ModifySerialization(
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
var target = new WithExceptionIgnoreMessage();
await Verify(target, settings);
await Verifier.Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L482-L491' title='File snippet `ignoremembersthatthrowexpression` was extracted from'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Navigate to start of snippet `ignoremembersthatthrowexpression`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L480-L489' title='File snippet `ignoremembersthatthrowexpression` was extracted from'>snippet source</a> | <a href='#snippet-ignoremembersthatthrowexpression' title='Navigate to start of snippet `ignoremembersthatthrowexpression`'>anchor</a></sup>
<!-- endsnippet -->
Result:
@ -598,9 +598,9 @@ By default newlines in json are escaped with `\r\n`:
<!-- snippet: NewLineEscapedInProperty -->
<a id='snippet-newlineescapedinproperty'/></a>
```cs
return Verify(new {Property = "a\r\nb\\nc"});
return Verifier.Verify(new {Property = "a\r\nb\\nc"});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L229-L231' title='File snippet `newlineescapedinproperty` was extracted from'>snippet source</a> | <a href='#snippet-newlineescapedinproperty' title='Navigate to start of snippet `newlineescapedinproperty`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L227-L229' title='File snippet `newlineescapedinproperty` was extracted from'>snippet source</a> | <a href='#snippet-newlineescapedinproperty' title='Navigate to start of snippet `newlineescapedinproperty`'>anchor</a></sup>
<!-- endsnippet -->
<!-- snippet: SerializationTests.NewLineEscapedInProperty.verified.txt -->
@ -620,9 +620,9 @@ This can be disabled:
```cs
var settings = new VerifySettings();
settings.DisableNewLineEscaping();
await Verify(new {Property = "a\r\nb\\nc"}, settings);
await Verifier.Verify(new {Property = "a\r\nb\\nc"}, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L237-L241' title='File snippet `disablenewlineescaping` was extracted from'>snippet source</a> | <a href='#snippet-disablenewlineescaping' title='Navigate to start of snippet `disablenewlineescaping`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L235-L239' title='File snippet `disablenewlineescaping` was extracted from'>snippet source</a> | <a href='#snippet-disablenewlineescaping' title='Navigate to start of snippet `disablenewlineescaping`'>anchor</a></sup>
<!-- endsnippet -->
<!-- snippet: SerializationTests.NewLineNotEscapedInProperty.verified.txt -->

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

@ -11,7 +11,6 @@ To change this file edit the source file and then run MarkdownSnippets.
[![NuGet Status](https://img.shields.io/nuget/v/Verify.Xunit.svg?label=Verify.Xunit)](https://www.nuget.org/packages/Verify.Xunit/)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.NUnit.svg?label=Verify.NUnit)](https://www.nuget.org/packages/Verify.NUnit/)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.MSTest.svg?label=Verify.MSTest)](https://www.nuget.org/packages/Verify.MSTest/)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.Bunit.svg?label=Verify.Bunit)](https://www.nuget.org/packages/Verify.Bunit/)
Verification tool to enable approval of complex models and documents.
@ -26,7 +25,6 @@ Support is available via a [Tidelift Subscription](https://tidelift.com/subscrip
* [xUnit](#xunit)
* [NUnit](#nunit)
* [MSTest](#mstest)
* [bunit](#bunit)
* [Initial Verification](#initial-verification)
* [Subsequent Verification](#subsequent-verification)
* [AutoVerify](#autoverify)
@ -60,7 +58,6 @@ Support is available via a [Tidelift Subscription](https://tidelift.com/subscrip
* https://nuget.org/packages/Verify.Xunit/
* https://nuget.org/packages/Verify.NUnit/
* https://nuget.org/packages/Verify.MSTest/
* https://nuget.org/packages/Verify.Bunit/
## Verification versus Assertion
@ -128,7 +125,7 @@ public void TraditionalTest()
Assert.Equal("USA", person.Address.Country);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L10-L26' title='File snippet `traditionaltest` was extracted from'>snippet source</a> | <a href='#snippet-traditionaltest' title='Navigate to start of snippet `traditionaltest`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L8-L24' title='File snippet `traditionaltest` was extracted from'>snippet source</a> | <a href='#snippet-traditionaltest' title='Navigate to start of snippet `traditionaltest`'>anchor</a></sup>
<!-- endsnippet -->
@ -141,10 +138,10 @@ public void TraditionalTest()
public Task Simple()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
return Verifier.Verify(person);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L28-L35' title='File snippet `verificationtest` was extracted from'>snippet source</a> | <a href='#snippet-verificationtest' title='Navigate to start of snippet `verificationtest`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L26-L33' title='File snippet `verificationtest` was extracted from'>snippet source</a> | <a href='#snippet-verificationtest' title='Navigate to start of snippet `verificationtest`'>anchor</a></sup>
<!-- endsnippet -->
@ -207,23 +204,18 @@ Support for [xUnit](https://xunit.net/)
<!-- snippet: SampleTestXunit -->
<a id='snippet-sampletestxunit'/></a>
```cs
public class Sample :
VerifyBase
public class Sample
{
[Fact]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
return Verifier.Verify(person);
}
public Sample(ITestOutputHelper output) :
base(output)
{
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/Sample.cs#L6-L22' title='File snippet `sampletestxunit` was extracted from'>snippet source</a> | <a href='#snippet-sampletestxunit' title='Navigate to start of snippet `sampletestxunit`'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/Sample.cs#L5-L16' title='File snippet `sampletestxunit` was extracted from'>snippet source</a> | <a href='#snippet-sampletestxunit' title='Navigate to start of snippet `sampletestxunit`'>anchor</a></sup>
<!-- endsnippet -->
* [Verify Xunit Intro](https://www.youtube.com/watch?v=uGVogEltSkY)
@ -274,76 +266,6 @@ public class Sample :
<!-- endsnippet -->
### bunit
Support for rendering a [Blazor Component](https://docs.microsoft.com/en-us/aspnet/core/blazor/#components) to a verified file via [bunit](https://bunit.egilhansen.com).
#### Component test
Given the following Component:
<!-- snippet: TestComponent.razor -->
<a id='snippet-TestComponent.razor'/></a>
```razor
<div>
<h1>@Title</h1>
<button>MyButton</button>
</div>
@code {
[Parameter]
public string Title { get; set; } = "My Test Component";
}
```
<sup><a href='/src/Verify.Bunit.Tests/TestComponent.razor#L1-L9' title='File snippet `TestComponent.razor` was extracted from'>snippet source</a> | <a href='#snippet-TestComponent.razor' title='Navigate to start of snippet `TestComponent.razor`'>anchor</a></sup>
<!-- endsnippet -->
This test:
<!-- snippet: ComponentTest -->
<a id='snippet-componenttest'/></a>
```cs
[Fact]
public Task Component()
{
var component = RenderComponent<TestComponent>();
return Verify(component);
}
```
<sup><a href='/src/Verify.Bunit.Tests/VerifyObjectSamples.cs#L16-L24' title='File snippet `componenttest` was extracted from'>snippet source</a> | <a href='#snippet-componenttest' title='Navigate to start of snippet `componenttest`'>anchor</a></sup>
<!-- endsnippet -->
Will produce:
The component rendered as html `...Component.verified.html`:
<!-- snippet: VerifyObjectSamples.Component.verified.html -->
<a id='snippet-VerifyObjectSamples.Component.verified.html'/></a>
```html
<div>
<h1>My Test Component</h1>
<button>MyButton</button>
</div>
```
<sup><a href='/src/Verify.Bunit.Tests/VerifyObjectSamples.Component.verified.html#L1-L4' title='File snippet `VerifyObjectSamples.Component.verified.html` was extracted from'>snippet source</a> | <a href='#snippet-VerifyObjectSamples.Component.verified.html' title='Navigate to start of snippet `VerifyObjectSamples.Component.verified.html`'>anchor</a></sup>
<!-- endsnippet -->
And the current model rendered as txt `...Component.info.verified.txt`:
<!-- snippet: VerifyObjectSamples.Component.info.verified.txt -->
<a id='snippet-VerifyObjectSamples.Component.info.verified.txt'/></a>
```txt
{
Instance: {
Title: 'My Test Component'
}
}
```
<sup><a href='/src/Verify.Bunit.Tests/VerifyObjectSamples.Component.info.verified.txt#L1-L5' title='File snippet `VerifyObjectSamples.Component.info.verified.txt` was extracted from'>snippet source</a> | <a href='#snippet-VerifyObjectSamples.Component.info.verified.txt' title='Navigate to start of snippet `VerifyObjectSamples.Component.info.verified.txt`'>anchor</a></sup>
<!-- endsnippet -->
### Initial Verification
When the test is initially run will fail with:
@ -471,7 +393,7 @@ This can be done using `AutoVerify()`:
var settings = new VerifySettings();
settings.AutoVerify();
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L85-L90' title='File snippet `autoverify` was extracted from'>snippet source</a> | <a href='#snippet-autoverify' title='Navigate to start of snippet `autoverify`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L83-L88' title='File snippet `autoverify` was extracted from'>snippet source</a> | <a href='#snippet-autoverify' title='Navigate to start of snippet `autoverify`'>anchor</a></sup>
<!-- endsnippet -->
Note that auto accepted changes in `.verified.` files remain visible in source control tooling.
@ -503,10 +425,10 @@ public async Task OnHandlersSample()
Debug.WriteLine(message);
return Task.CompletedTask;
});
await Verify("value", settings);
await Verifier.Verify("value", settings);
}
```
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L14-L34' title='File snippet `onhandlers` was extracted from'>snippet source</a> | <a href='#snippet-onhandlers' title='Navigate to start of snippet `onhandlers`'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/Snippets.cs#L12-L32' title='File snippet `onhandlers` was extracted from'>snippet source</a> | <a href='#snippet-onhandlers' title='Navigate to start of snippet `onhandlers`'>anchor</a></sup>
<!-- endsnippet -->

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

@ -4,7 +4,6 @@
[![NuGet Status](https://img.shields.io/nuget/v/Verify.Xunit.svg?label=Verify.Xunit)](https://www.nuget.org/packages/Verify.Xunit/)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.NUnit.svg?label=Verify.NUnit)](https://www.nuget.org/packages/Verify.NUnit/)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.MSTest.svg?label=Verify.MSTest)](https://www.nuget.org/packages/Verify.MSTest/)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.Bunit.svg?label=Verify.Bunit)](https://www.nuget.org/packages/Verify.Bunit/)
Verification tool to enable approval of complex models and documents.
@ -19,7 +18,6 @@ include: doc-index
* https://nuget.org/packages/Verify.Xunit/
* https://nuget.org/packages/Verify.NUnit/
* https://nuget.org/packages/Verify.MSTest/
* https://nuget.org/packages/Verify.Bunit/
## Verification versus Assertion
@ -93,32 +91,6 @@ Support for [MSTest](https://github.com/Microsoft/testfx-docs)
snippet: SampleTestMSTest
### bunit
Support for rendering a [Blazor Component](https://docs.microsoft.com/en-us/aspnet/core/blazor/#components) to a verified file via [bunit](https://bunit.egilhansen.com).
#### Component test
Given the following Component:
snippet: TestComponent.razor
This test:
snippet: ComponentTest
Will produce:
The component rendered as html `...Component.verified.html`:
snippet: VerifyObjectSamples.Component.verified.html
And the current model rendered as txt `...Component.info.verified.txt`:
snippet: VerifyObjectSamples.Component.info.verified.txt
### Initial Verification
When the test is initially run will fail with:

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

@ -1,19 +1,13 @@
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class Tests :
VerifyBase
[InjectInfo]
public class Tests
{
[Fact]
public Task Simple()
{
return Verify("Foo");
}
public Tests(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify("Foo");
}
}

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

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649</NoWarn>
<Version>4.3.1</Version>
<NoWarn>CS1591;CS0649;xUnit1026</NoWarn>
<Version>5.0.0-beta.1</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<PackageTags>Json, Testing, Verify, Snapshot, Approvals</PackageTags>
<Description>Enables verification of complex models and documents.</Description>

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

@ -1,11 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Verify\Verify.csproj" />
</ItemGroup>
</Project>

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

@ -1 +0,0 @@
A B C

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

@ -1,37 +0,0 @@
using System.Threading.Tasks;
using Verify;
using VerifyBunit;
using Xunit;
using Xunit.Abstractions;
#region ScrubberLevelsSampleBunit
public class ScrubberLevelsSample :
VerifyBase
{
VerifySettings classLevelSettings;
public ScrubberLevelsSample(ITestOutputHelper output) :
base(output)
{
classLevelSettings = new VerifySettings();
classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
}
[Fact]
public Task Usage()
{
var settings = new VerifySettings(classLevelSettings);
settings.AddScrubber(s => s.Replace("Two", "B"));
return Verify("One Two Three", settings);
}
[GlobalSetUp]
public static class GlobalSetup
{
public static void Setup()
{
SharedVerifySettings.AddScrubber(s => s.Replace("One", "A"));
}
}
}
#endregion

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

@ -1,5 +0,0 @@
LineA
LineC
NoMoreLineE
LineI

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

@ -1,3 +0,0 @@
{
RowVersion: 'TheRowVersion'
}

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

@ -1,60 +0,0 @@
using System;
using System.Threading.Tasks;
using Verify;
using VerifyBunit;
using Xunit;
using Xunit.Abstractions;
#region ScrubbersSampleBunit
public class ScrubbersSample :
VerifyBase
{
public ScrubbersSample(ITestOutputHelper output) :
base(output)
{
}
[Fact]
public Task Lines()
{
var settings = new VerifySettings();
settings.ScrubLinesWithReplace(
replaceLine: line =>
{
if (line == "LineE")
{
return "NoMoreLineE";
}
return line;
});
settings.ScrubLines(removeLine: line => line.Contains("J"));
settings.ScrubLinesContaining("b", "D");
settings.ScrubLinesContaining(StringComparison.Ordinal, "H");
return Verify(
settings: settings,
target: @"
LineA
LineB
LineC
LineD
LineE
LineH
LineI
LineJ
");
}
[Fact]
public Task ScrubberAppliedAfterJsonSerialization()
{
var target = new ToBeScrubbed
{
RowVersion = "0x00000000000007D3"
};
var settings = new VerifySettings();
settings.AddScrubber(
input => input.Replace("0x00000000000007D3", "TheRowVersion"));
return Verify(target, settings);
}
}
#endregion

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

@ -1,14 +0,0 @@
{
GivenNames: 'John',
FamilyName: 'Smith',
Spouse: 'Jill',
Address: {
Street: '4 Puddle Lane',
Country: 'USA'
},
Children: [
'Sam',
'Mary'
],
Id: Guid_1
}

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

@ -1,22 +0,0 @@
using System.Threading.Tasks;
using VerifyBunit;
using Xunit;
using Xunit.Abstractions;
#region SampleTestBunit
public class Sample :
VerifyBase
{
[Fact]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
}
public Sample(ITestOutputHelper output) :
base(output)
{
}
}
#endregion

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

@ -1 +0,0 @@
value

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

@ -1 +0,0 @@
value

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

@ -1 +0,0 @@
value

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

@ -1 +0,0 @@
value

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

@ -1 +0,0 @@
value

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

@ -1 +0,0 @@
value

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

@ -1,40 +0,0 @@
using System.Threading.Tasks;
using Verify;
using VerifyBunit;
using Xunit;
using Xunit.Abstractions;
#region UniqueForSampleBunit
public class UniqueForSample :
VerifyBase
{
[Fact]
public Task Runtime()
{
var settings = new VerifySettings();
settings.UniqueForRuntime();
return Verify("value", settings);
}
[Fact]
public Task RuntimeAndVersion()
{
var settings = new VerifySettings();
settings.UniqueForRuntimeAndVersion();
return Verify("value", settings);
}
[Fact]
public Task AssemblyConfiguration()
{
var settings = new VerifySettings();
settings.UniqueForAssemblyConfiguration();
return Verify("value", settings);
}
public UniqueForSample(ITestOutputHelper output) :
base(output)
{
}
}
#endregion

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

@ -1,9 +0,0 @@
<div>
<h1>@Title</h1>
<button>MyButton</button>
</div>
@code {
[Parameter]
public string Title { get; set; } = "My Test Component";
}

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

@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.4" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" />
<PackageReference Include="bunit" Version="1.0.0-beta-7" />
<PackageReference Include="ProjectDefaults" Version="1.0.43" PrivateAssets="All" />
<ProjectReference Include="..\TargetLibrary\TargetLibrary.csproj" />
<ProjectReference Include="..\Verify.Bunit\Verify.Bunit.csproj" />
<ProjectReference Include="..\Verify\Verify.csproj" />
</ItemGroup>
<Import Project="$(ProjectDir)..\Verify\build\Verify.targets" />
</Project>

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

@ -1,10 +0,0 @@
{
person1: {
GivenNames: 'John',
FamilyName: 'Smith'
},
person2: {
GivenNames: 'Marianne',
FamilyName: 'Aguirre'
}
}

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

@ -1,5 +0,0 @@
{
Instance: {
Title: 'My Test Component'
}
}

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

@ -1,4 +0,0 @@
<div>
<h1>My Test Component</h1>
<button>MyButton</button>
</div>

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

@ -1,9 +0,0 @@
{
OtherProp: 'Foo',
Component: {
Instance: {
Title: 'My Test Component'
},
Markup: '<div>\n <h1>My Test Component</h1>\n <button>MyButton</button>\n</div>'
}
}

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

@ -1,5 +0,0 @@
{
GivenNames: 'John',
FamilyName: 'Smith',
Dob: '\/Date(970358400000+0000)\/'
}

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

@ -1,147 +0,0 @@
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Verify;
using Verify.Bunit.Tests;
using VerifyBunit;
using Xunit;
using Xunit.Abstractions;
// Non-nullable field is uninitialized
#pragma warning disable CS8618
public class VerifyObjectSamples :
VerifyBase
{
#region ComponentTest
[Fact]
public Task Component()
{
var component = RenderComponent<TestComponent>();
return Verify(component);
}
#endregion
[Fact]
public Task Nested()
{
var component = RenderComponent<TestComponent>();
return Verify(new
{
OtherProp = "Foo",
Component = component
});
}
async Task ChangeDefaultsPerVerification(object target)
{
#region ChangeDefaultsPerVerificationBunit
var settings = new VerifySettings();
settings.ModifySerialization(_ =>
{
_.DontIgnoreEmptyCollections();
_.DontScrubGuids();
_.DontScrubDateTimes();
_.DontIgnoreFalse();
});
await Verify(target, settings);
#endregion
}
[Fact]
public async Task ScopedSerializer()
{
var person = new Person
{
GivenNames = "John",
FamilyName = "Smith",
Dob = new DateTimeOffset(2000, 10, 1, 0, 0, 0, TimeSpan.Zero),
};
var settings = new VerifySettings();
settings.ModifySerialization(_ => _.DontScrubDateTimes());
settings.AddExtraSettings(_ => _.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat);
await Verify(person, settings);
}
async Task Before()
{
var person = new Person
{
GivenNames = "John",
FamilyName = "Smith",
Spouse = "Jill",
Address = new Address
{
Street = "1 Puddle Lane",
Country = "USA"
}
};
await Verify(person);
}
#region AnonBunit
[Fact]
public async Task Anon()
{
var person1 = new Person
{
GivenNames = "John",
FamilyName = "Smith"
};
var person2 = new Person
{
GivenNames = "Marianne",
FamilyName = "Aguirre"
};
await Verify(
new
{
person1,
person2
});
}
#endregion
async Task After()
{
var person = new Person
{
GivenNames = "John",
FamilyName = "Smith",
Spouse = "Jill",
Address = new Address
{
Street = "1 Puddle Lane",
Suburb = "Gotham",
Country = "USA"
}
};
await Verify(person);
}
class Person
{
public string GivenNames;
public string FamilyName;
public string Spouse;
public Address Address;
public DateTimeOffset Dob;
}
class Address
{
public string Street;
public string Country;
public string Suburb;
}
public VerifyObjectSamples(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -1 +0,0 @@
Foo

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

@ -1,19 +0,0 @@
using System.Threading.Tasks;
using VerifyBunit;
using Xunit;
using Xunit.Abstractions;
public class VerifyTextSample :
VerifyBase
{
[Fact]
public Task Simple()
{
return Verify("Foo");
}
public VerifyTextSample(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -1,27 +0,0 @@
using System.Linq;
using Bunit;
static class ComponentReader
{
public static object? GetInstance(IRenderedFragment fragment)
{
var type = fragment.GetType();
if (!type.IsGenericType)
{
return null;
}
var renderComponentInterface = type
.GetInterfaces()
.SingleOrDefault(x =>
x.IsGenericType &&
x.GetGenericTypeDefinition() == typeof(IRenderedComponentBase<>));
if (renderComponentInterface == null)
{
return null;
}
var instanceProperty = renderComponentInterface.GetProperty("Instance");
return instanceProperty.GetValue(fragment);
}
}

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

@ -1,9 +0,0 @@
class FragmentInfo
{
public object? Instance { get; }
public FragmentInfo(object? instance)
{
Instance = instance;
}
}

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

@ -1,17 +0,0 @@
using System.IO;
using Bunit;
using Verify;
static class FragmentToStream
{
public static ConversionResult Convert(IRenderedFragment fragment, VerifySettings settings)
{
var stream = new MemoryStream();
using var writer = stream.BuildLeaveOpenWriter();
writer.WriteLine(fragment.Markup);
var instance = ComponentReader.GetInstance(fragment);
return new ConversionResult(new FragmentInfo(instance), stream);
}
}

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

@ -1,3 +0,0 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleTo("Verify.Bunit.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001000f0a8e4bf1639dce01be6592384e7dfc621915b7759fb5cee42ec5d351bcc43460432da1659ee618ca6cab6b8b8e56a5deb5d4ee1a49783d5c2690752502d31ccbfee9b2c697e20359b55ad100cc9370c8e983fd9496f01d761a060d0435bac7243b1832ba95757aa5adbb67df38c213d717b6751e1217cea9fa5c61e9b799dd")]

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

@ -1,25 +0,0 @@
using Bunit;
using Verify;
using Xunit;
using Xunit.Sdk;
static class ModuleInitializer
{
public static void Initialize()
{
InnerVerifier.Init(
message => new XunitException(message),
input => XunitContext.Context.IntOrNext(input),
input => XunitContext.Context.IntOrNext(input),
input => XunitContext.Context.IntOrNext(input));
SharedVerifySettings.RegisterFileConverter<IRenderedFragment>("html", FragmentToStream.Convert);
SharedVerifySettings.ModifySerialization(settings =>
{
settings.AddExtraSettings(serializerSettings =>
{
var converters = serializerSettings.Converters;
converters.Add(new RenderedFragmentConverter());
});
});
}
}

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

@ -1,23 +0,0 @@
using Bunit;
using Newtonsoft.Json;
using Verify;
class RenderedFragmentConverter : WriteOnlyJsonConverter<IRenderedFragment>
{
public override void WriteJson(JsonWriter writer, IRenderedFragment? fragment, JsonSerializer serializer)
{
if (fragment == null)
{
return;
}
writer.WriteStartObject();
writer.WritePropertyName("Instance");
serializer.Serialize(writer, ComponentReader.GetInstance(fragment));
writer.WritePropertyName("Markup");
serializer.Serialize(writer, fragment.Markup);
writer.WriteEndObject();
}
}

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

@ -1,12 +0,0 @@
using System.IO;
using System.Text;
static class StreamHelpers
{
static Encoding utf8NoBOM = new UTF8Encoding(false, true);
public static StreamWriter BuildLeaveOpenWriter(this Stream input)
{
return new StreamWriter(input, utf8NoBOM, 1024, leaveOpen: true);
}
}

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

@ -5,17 +5,7 @@
<Version>$(Version)</Version>
</PropertyGroup>
<ItemGroup>
<Content Include="buildMultiTargeting.targets" PackagePath="buildMultiTargeting\Verify.Bunit.targets" />
<Content Include="build.targets" PackagePath="build\Verify.Bunit.targets" />
<PackageReference Include="EmptyFiles" Version="2.0.3" PrivateAssets="None" />
<PackageReference Include="xunit.assert" Version="2.4.1" />
<PackageReference Include="XunitContext" Version="1.9.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Fody" Version="6.2.0" PrivateAssets="all" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.0" PrivateAssets="All" />
<PackageReference Include="bunit" Version="1.0.0-beta-7" />
<PackageReference Include="ProjectDefaults" Version="1.0.43" PrivateAssets="All" />
<PackageReference Include="Nullable" Version="1.2.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />
<ProjectReference Include="..\Verify\Verify.csproj" PrivateAssets="None" />
</ItemGroup>

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

@ -1,37 +1,11 @@
using System.Runtime.CompilerServices;
using Bunit;
using Xunit;
using Xunit.Abstractions;
using System;
namespace VerifyBunit
{
public partial class VerifyBase :
TestContext
[Obsolete(
"Verify.Bunit is no longer required. Switch to Verify.Xunit which no longer requires a base class and can be used to verify the rendered result from bunit.",
error: true)]
public class VerifyBase
{
public VerifyBase(
ITestOutputHelper output,
[CallerFilePath] string sourceFile = "")
{
XunitContext.Register(output, sourceFile);
}
InnerVerifier GetVerifier()
{
var context = XunitContext.Context;
return new InnerVerifier(context.TestType, context.SourceDirectory, context.UniqueTestName);
}
//TODO: move the ContextCleanup back into the dispose when bunit is released
//protected override void Dispose(bool disposing)
//{
// base.Dispose(disposing);
// XunitContext.Flush();
//}
//TODO: remove when bunit is released
protected void Flush()
{
XunitContext.Flush();
}
}
}

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

@ -1,45 +0,0 @@
using System.IO;
using System.Threading.Tasks;
using Verify;
namespace VerifyBunit
{
public partial class VerifyBase
{
public async Task Verify(
byte[] target,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(target, settings);
Flush();
}
public async Task Verify(
Task<byte[]> target,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(await target, settings);
Flush();
}
public async Task VerifyFile(
string path,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.VerifyFile(path, settings);
Flush();
}
public async Task VerifyFile(
FileInfo file,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.VerifyFile(file, settings);
Flush();
}
}
}

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

@ -1,36 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Verify;
namespace VerifyBunit
{
public partial class VerifyBase
{
public async Task Verify<T>(
Task<T> target,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(target, settings);
Flush();
}
public async Task Verify<T>(
IAsyncEnumerable<T> target,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(target, settings);
Flush();
}
public async Task Verify<T>(
T target,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(target, settings);
Flush();
}
}
}

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

@ -1,15 +0,0 @@
using System.Threading.Tasks;
using Verify;
namespace VerifyBunit
{
public partial class VerifyBase
{
public async Task Verify(string target, VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(target, settings);
Flush();
}
}
}

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

@ -1,22 +0,0 @@
#if !NETSTANDARD2_0
using System;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Verify;
namespace VerifyBunit
{
public partial class VerifyBase
{
public async Task Verify(
Expression<Func<ITuple>> expression,
VerifySettings? settings = null)
{
var verifier = GetVerifier();
await verifier.Verify(expression, settings);
Flush();
}
}
}
#endif

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

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<PropertyGroup>
<Deterministic>false</Deterministic>
<DeterministicSourcePaths>false</DeterministicSourcePaths>
</PropertyGroup>
</Project>

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

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="..\build\Verify.Bunit.targets"/>
</Project>

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

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" GenerateXsd="false">
<InfoOf />
</Weavers>

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

@ -13,8 +13,9 @@ using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
[InjectInfo]
public partial class Tests :
VerifyBase
XunitContextBase
{
static string diffToolPath = Path.GetFullPath(Path.Combine(AssemblyLocation.CurrentDirectory, "../../../../FakeDiffTool/bin/FakeDiffTool.exe"));

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

@ -7,25 +7,29 @@ using Verify;
using VerifyXunit;
using Xunit;
public partial class Tests :
VerifyBase
public partial class Tests
{
[Theory]
[InlineData(false, false)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(true, true)]
public Task Text(
public async Task Text(
bool hasExistingReceived,
bool autoVerify)
{
return RunTest(
var uniqueTestName = TestNameBuilder.GetUniqueTestName("Tests_Single",Info.OfMethod<Tests>("Text"),new object[]{hasExistingReceived, autoVerify});
var settings = new VerifySettings();
settings.UseParameters(hasExistingReceived, autoVerify);
await RunTest(
"txt",
() => "someText",
() => "someOtherText",
hasMatchingDiffTool: true,
hasExistingReceived,
autoVerify);
autoVerify,
settings,
uniqueTestName);
}
[Theory]
@ -37,20 +41,25 @@ public partial class Tests :
[InlineData(false, true, true)]
[InlineData(false, false, true)]
[InlineData(true, true, true)]
public Task Stream(
public async Task Stream(
bool hasMatchingDiffTool,
bool hasExistingReceived,
bool autoVerify)
{
var extension = hasMatchingDiffTool ? "knownBin" : "unknownBin";
return RunTest(
var uniqueTestName = TestNameBuilder.GetUniqueTestName("Tests_Single", Info.OfMethod<Tests>("Stream"), new object[] {hasMatchingDiffTool, hasExistingReceived, autoVerify});
var settings = new VerifySettings();
settings.UseParameters(hasMatchingDiffTool, hasExistingReceived, autoVerify);
await RunTest(
extension: extension,
() => new MemoryStream(new byte[] {1}),
() => new MemoryStream(new byte[] {2}),
hasMatchingDiffTool,
hasExistingReceived,
autoVerify);
autoVerify,
settings,
uniqueTestName);
}
async Task RunTest(
@ -59,16 +68,16 @@ public partial class Tests :
Func<object> secondTarget,
bool hasMatchingDiffTool,
bool hasExistingReceived,
bool autoVerify)
bool autoVerify,
VerifySettings settings,
string uniqueTestName)
{
var settings = new VerifySettings();
settings.UseExtension(extension);
if (autoVerify)
{
settings.AutoVerify();
}
var prefix = Path.Combine(SourceDirectory, $"{Context.UniqueTestName}");
var prefix = Path.Combine(SourceDirectory, uniqueTestName);
var danglingFile = Path.Combine(SourceDirectory, $"{prefix}.01.verified.{extension}");
var file = new FilePair(extension, prefix);
@ -105,7 +114,7 @@ public partial class Tests :
{
var command = BuildCommand(pair);
ProcessCleanup.Refresh();
await Verify(target(), settings);
await Verifier.Verify(target(), settings);
ProcessCleanup.Refresh();
AssertProcessNotRunning(command);
@ -117,12 +126,12 @@ public partial class Tests :
{
if (settings.autoVerify)
{
await Verify(target(), settings);
await Verifier.Verify(target(), settings);
AssertExists(pair.Verified);
}
else
{
await Throws(() => Verify(target(), settings));
await Throws(() => Verifier.Verify(target(), settings));
ProcessCleanup.Refresh();
AssertProcess(hasMatchingDiffTool, pair);
if (hasMatchingDiffTool)

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

@ -7,40 +7,28 @@ using Verify;
using VerifyXunit;
using Xunit;
public partial class Tests :
VerifyBase
public partial class Tests
{
[Theory]
[InlineData(false, false)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(true, true)]
public Task Split(
bool hasExistingReceived,
bool autoVerify)
{
return RunSplitTest(
new TypeToSplit("info1","value1","value2"),
new TypeToSplit("info2","value1.1","value2.1"),
hasMatchingDiffTool: true,
hasExistingReceived,
autoVerify);
}
async Task RunSplitTest(
TypeToSplit initialTarget,
TypeToSplit secondTarget,
bool hasMatchingDiffTool,
public async Task Split(
bool hasExistingReceived,
bool autoVerify)
{
TypeToSplit initialTarget = new TypeToSplit("info1", "value1", "value2");
TypeToSplit secondTarget = new TypeToSplit("info2", "value1.1", "value2.1");
var settings = new VerifySettings();
if (autoVerify)
{
settings.AutoVerify();
}
var uniqueTestName = TestNameBuilder.GetUniqueTestName("Tests_Split", Info.OfMethod<Tests>("Split"), new object[] {hasExistingReceived, autoVerify});
var prefix = Path.Combine(SourceDirectory, $"{Context.UniqueTestName}.");
settings.UseParameters(hasExistingReceived, autoVerify);
var prefix = Path.Combine(SourceDirectory, $"{uniqueTestName}.");
var danglingFile = $"{prefix}03.verified.txt";
var info = new FilePair("txt", $"{prefix}info");
var file1 = new FilePair("txt", $"{prefix}00");
@ -56,8 +44,7 @@ public partial class Tests :
File.WriteAllText(file2.Received, "");
}
await InitialVerifySplit(initialTarget, hasMatchingDiffTool, settings, info, file1, file2);
await InitialVerifySplit(initialTarget, true, settings, info, file1, file2);
if (!autoVerify)
{
@ -68,7 +55,7 @@ public partial class Tests :
await ReVerifySplit(initialTarget, settings, info, file1, file2);
await InitialVerifySplit(secondTarget, hasMatchingDiffTool, settings, info, file1, file2);
await InitialVerifySplit(secondTarget, true, settings, info, file1, file2);
if (!autoVerify)
{
@ -84,7 +71,7 @@ public partial class Tests :
var file1Command = BuildCommand(file1);
var file2Command = BuildCommand(file2);
ProcessCleanup.Refresh();
await Verify(target, settings);
await Verifier.Verify(target, settings);
ProcessCleanup.Refresh();
AssertProcessNotRunning(infoCommand);
AssertProcessNotRunning(file1Command);
@ -102,16 +89,16 @@ public partial class Tests :
{
if (settings.autoVerify)
{
await Verify(target, settings);
await Verifier.Verify(target, settings);
AssertExists(info.Verified);
AssertExists(file1.Verified);
AssertExists(file2.Verified);
}
else
{
await Throws(() => Verify(target, settings));
await Throws(() => Verifier.Verify(target, settings));
ProcessCleanup.Refresh();
AssertProcess( hasMatchingDiffTool, info,file1, file2);
AssertProcess(hasMatchingDiffTool, info, file1, file2);
if (hasMatchingDiffTool)
{
AssertExists(info.Verified);

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

@ -6,13 +6,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DiffEngine" Version="3.2.2" />
<PackageReference Include="InfoOf.Fody" Version="1.6.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Xunit" Version="2.4.1" />
<PackageReference Include="Fody" Version="6.2.0" PrivateAssets="all" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.2" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" Condition="$(Configuration) == 'Release'" />
<PackageReference Include="ProjectDefaults" Version="1.0.43" PrivateAssets="All" />
<PackageReference Include="XunitContext" Version="1.9.4" />
<ProjectReference Include="..\Verify.Xunit\Verify.Xunit.csproj" />
<ProjectReference Include="..\Verify\Verify.csproj" />
</ItemGroup>

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

@ -4,10 +4,6 @@ static class ModuleInitializer
{
public static void Initialize()
{
InnerVerifier.Init(
message => new AssertFailedException(message),
input => CounterContext.Current.IntOrNext(input),
input => CounterContext.Current.IntOrNext(input),
input => CounterContext.Current.IntOrNext(input));
InnerVerifier.Init(message => new AssertFailedException(message));
}
}

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

@ -9,7 +9,6 @@
<ItemGroup>
<Content Include="buildMultiTargeting.targets" PackagePath="buildMultiTargeting\Verify.MSTest.targets" />
<Content Include="build.targets" PackagePath="build\Verify.MSTest.targets" />
<Compile Include="..\Shared\*.cs" />
<PackageReference Include="EmptyFiles" Version="2.0.3" PrivateAssets="None" />
<PackageReference Include="Fody" Version="6.2.0" PrivateAssets="all" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.0" PrivateAssets="All" />

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

@ -4,10 +4,6 @@ static class ModuleInitializer
{
public static void Initialize()
{
InnerVerifier.Init(
message => new NUnitException(message),
input => CounterContext.Current.IntOrNext(input),
input => CounterContext.Current.IntOrNext(input),
input => CounterContext.Current.IntOrNext(input));
InnerVerifier.Init(message => new NUnitException(message));
}
}

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

@ -8,7 +8,6 @@
<ItemGroup>
<Content Include="build.targets" PackagePath="build\Verify.NUnit.targets" />
<Content Include="buildMultiTargeting.targets" PackagePath="buildMultiTargeting\Verify.NUnit.targets" />
<Compile Include="..\Shared\*.cs" />
<PackageReference Include="Fody" Version="6.2.0" PrivateAssets="all" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.0" PrivateAssets="All" />
<PackageReference Include="EmptyFiles" Version="2.0.3" PrivateAssets="None" />

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

@ -1,12 +1,9 @@
using System;
using System.Text;
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class ClipboardEnabledTests :
VerifyBase
public class ClipboardEnabledTests
{
[Fact]
public void ParseEnvironmentVariable()
@ -19,14 +16,7 @@ public class ClipboardEnabledTests :
[Fact]
public Task ParseEnvironmentVariable_failure()
{
StringBuilder builder = new StringBuilder();
builder.Equals(new StringBuilder());
var exception = Assert.Throws<Exception>(() => ClipboardEnabled.ParseEnvironmentVariable("foo"));
return Verify(exception);
}
public ClipboardEnabledTests(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify(exception);
}
}

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

@ -4,11 +4,9 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
public class ComparerTests :
VerifyBase
public class ComparerTests
{
[Fact]
public async Task Instance_with_message()
@ -17,7 +15,7 @@ public class ComparerTests :
settings.UseComparer(CompareWithMessage);
settings.DisableDiff();
settings.DisableClipboard();
var exception = await Assert.ThrowsAsync<XunitException>(() => Verify("NotTheText", settings));
var exception = await Assert.ThrowsAsync<XunitException>(() => Verifier.Verify("NotTheText", settings));
Assert.Contains("theMessage", exception.Message);
}
@ -26,8 +24,8 @@ public class ComparerTests :
{
var settings = new VerifySettings();
settings.UseComparer(Compare);
await Verify("TheText", settings);
await Verify("thetext", settings);
await Verifier.Verify("TheText", settings);
await Verifier.Verify("thetext", settings);
}
[Fact]
@ -38,7 +36,7 @@ public class ComparerTests :
settings.UseExtension("staticComparerExtMessage");
settings.DisableDiff();
settings.DisableClipboard();
var exception = await Assert.ThrowsAsync<XunitException>(() => Verify("TheText", settings));
var exception = await Assert.ThrowsAsync<XunitException>(() => Verifier.Verify("TheText", settings));
Assert.Contains("theMessage", exception.Message);
}
@ -48,8 +46,8 @@ public class ComparerTests :
SharedVerifySettings.RegisterComparer("staticComparerExt", Compare);
var settings = new VerifySettings();
settings.UseExtension("staticComparerExt");
await Verify("TheText", settings);
await Verify("thetext", settings);
await Verifier.Verify("TheText", settings);
await Verifier.Verify("thetext", settings);
}
static async Task<CompareResult> Compare(VerifySettings settings, Stream received, Stream verified)
@ -63,9 +61,4 @@ public class ComparerTests :
{
return Task.FromResult(CompareResult.NotEqual("theMessage"));
}
public ComparerTests(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -7,10 +7,8 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class ExtensionConverterTests :
VerifyBase
public class ExtensionConverterTests
{
[Fact]
public Task TextSplit()
@ -21,7 +19,7 @@ public class ExtensionConverterTests :
(stream, _) => new ConversionResult(null, stream));
var settings = new VerifySettings();
settings.UseExtension("txt");
return Verify(FileHelpers.OpenRead("sample.split"), settings);
return Verifier.Verify(FileHelpers.OpenRead("sample.split"), settings);
}
[Fact]
@ -37,7 +35,7 @@ public class ExtensionConverterTests :
});
var settings = new VerifySettings();
settings.UseExtension("bmp");
return Verify(FileHelpers.OpenRead("sample.bmp"), settings);
return Verifier.Verify(FileHelpers.OpenRead("sample.bmp"), settings);
}
[Fact]
@ -53,7 +51,7 @@ public class ExtensionConverterTests :
});
var settings = new VerifySettings();
settings.UseExtension("bmp");
return Verify(FileHelpers.OpenRead("sample.bmp"), settings);
return Verifier.Verify(FileHelpers.OpenRead("sample.bmp"), settings);
}
[Fact]
@ -73,7 +71,7 @@ public class ExtensionConverterTests :
});
var settings = new VerifySettings();
settings.UseExtension("bmp");
return Verify(FileHelpers.OpenRead("sample.bmp"), settings);
return Verifier.Verify(FileHelpers.OpenRead("sample.bmp"), settings);
}
static IEnumerable<Stream> ConvertBmpTpPngStreams(Stream input)
@ -83,10 +81,5 @@ public class ExtensionConverterTests :
bitmap.Save(stream, ImageFormat.Png);
yield return stream;
}
public ExtensionConverterTests(ITestOutputHelper output) :
base(output)
{
}
}
#endif

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

@ -8,10 +8,8 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class TypeConverterTests :
VerifyBase
public class TypeConverterTests
{
[Fact]
public Task Inherited()
@ -30,14 +28,15 @@ public class TypeConverterTests :
};
var settings = new VerifySettings();
settings.UseExtension("txt");
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
[Fact]
public Task DifferingExtensions()
{
SharedVerifySettings.RegisterFileConverter<ClassToSplit3>(
"notTxt", async (classToSplit, _) =>
"notTxt",
async (classToSplit, _) =>
{
await Task.Delay(1);
throw new Exception();
@ -57,7 +56,7 @@ public class TypeConverterTests :
};
var settings = new VerifySettings();
settings.UseExtension("txt");
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
static List<Stream> ToStream(string splitValue)
@ -95,7 +94,7 @@ public class TypeConverterTests :
};
var settings = new VerifySettings();
settings.UseExtension("txt");
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
public class ClassToSplit2
@ -117,7 +116,7 @@ public class TypeConverterTests :
{
Value = $@"line1{Environment.NewLine}line2"
};
return Verify(target);
return Verifier.Verify(target);
}
public class ClassToSplit
@ -140,7 +139,7 @@ public class TypeConverterTests :
{
Value = "Invalid"
};
return Verify(target);
return Verifier.Verify(target);
}
[Fact]
@ -158,7 +157,7 @@ public class TypeConverterTests :
{
Value = "Valid"
};
return Verify(target);
return Verifier.Verify(target);
}
public class CanConvertTarget
@ -183,7 +182,7 @@ public class TypeConverterTests :
var settings = new VerifySettings();
settings.UseExtension("bmp");
var bitmap = new Bitmap(FileHelpers.OpenRead("sample.bmp"));
return Verify(bitmap, settings);
return Verifier.Verify(bitmap, settings);
}
[Fact]
@ -205,7 +204,7 @@ public class TypeConverterTests :
settings.UseExtension("bmp");
settings.ModifySerialization(_ => { _.IgnoreMember("Property"); });
var bitmap = new Bitmap(FileHelpers.OpenRead("sample.bmp"));
return Verify(bitmap, settings);
return Verifier.Verify(bitmap, settings);
}
[Fact]
@ -222,7 +221,7 @@ public class TypeConverterTests :
var settings = new VerifySettings();
settings.UseExtension("bmp");
var bitmap = new Bitmap(FileHelpers.OpenRead("sample.bmp"));
return Verify(bitmap, settings);
return Verifier.Verify(bitmap, settings);
}
static IEnumerable<Stream> ConvertBmpTpPngStreams(Bitmap bitmap)
@ -231,10 +230,5 @@ public class TypeConverterTests :
bitmap.Save(stream, ImageFormat.Png);
yield return stream;
}
public TypeConverterTests(ITestOutputHelper output) :
base(output)
{
}
}
#endif

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

@ -1,12 +1,9 @@
using System.IO;
using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class FileComparerTests :
VerifyBase
public class FileComparerTests
{
[Fact]
public async Task BinaryEquals()
@ -71,9 +68,4 @@ public class FileComparerTests :
File.Delete("sample.tmp");
}
}
public FileComparerTests(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -1,9 +1,6 @@
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
using Xunit;
public class FileHelperTests :
VerifyBase
public class FileHelperTests
{
[Fact]
public void ShouldNotLock()
@ -13,9 +10,4 @@ public class FileHelperTests :
Assert.False(FileEx.IsFileReadLocked("sample.txt"));
}
}
public FileHelperTests(ITestOutputHelper output) :
base(output)
{
}
}

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

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

@ -3,17 +3,15 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class LinesScrubberTests :
VerifyBase
public class LinesScrubberTests
{
[Fact]
public Task ScrubLinesContaining()
{
var settings = new VerifySettings();
settings.ScrubLinesContaining("c", "D", "F");
return Verify(
return Verifier.Verify(
settings: settings,
target: @"a
b
@ -28,7 +26,7 @@ f");
{
var settings = new VerifySettings();
settings.ScrubLines(removeLine: x => x.Contains("D"));
return Verify(
return Verifier.Verify(
settings: settings,
target: @"b
");
@ -39,7 +37,7 @@ f");
{
var settings = new VerifySettings();
settings.ScrubLines(removeLine: x => x.Contains("D"));
return Verify(
return Verifier.Verify(
settings: settings,
target: @"b
@ -51,7 +49,7 @@ c");
{
var settings = new VerifySettings();
settings.ScrubLines(removeLine: x => x.Contains("D"));
return Verify(
return Verifier.Verify(
settings: settings,
target: @"a
b
@ -66,7 +64,7 @@ f");
{
var settings = new VerifySettings();
settings.ScrubLinesContaining(StringComparison.Ordinal, "c", "D", "F");
return Verify(
return Verifier.Verify(
settings: settings,
target: @"a
b
@ -75,9 +73,4 @@ D
e
f");
}
public LinesScrubberTests(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -0,0 +1,10 @@
using System.Reflection;
using VerifyXunit;
static class ModuleInitializer
{
public static void Initialize()
{
Verifier.SetTestAssembly(Assembly.GetExecutingAssembly());
}
}

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

@ -1,22 +1,15 @@
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
namespace TheNamespace.Bar
{
public class NamerInNamespaceTests :
VerifyBase
public class NamerInNamespaceTests
{
[Fact]
public Task Run()
{
return Verify("value");
}
public NamerInNamespaceTests(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify("value");
}
}
}

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

@ -5,17 +5,15 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class NamerTests :
VerifyBase
public class NamerTests
{
[Fact]
public Task Runtime()
{
var settings = new VerifySettings();
settings.UniqueForRuntime();
return Verify(Namer.Runtime, settings);
return Verifier.Verify(Namer.Runtime, settings);
}
[Fact]
@ -32,7 +30,7 @@ public class NamerTests :
receivedProjectDirectory = projectDirectory;
return testDirectory;
});
await Verify("DeriveTestDirectory");
await Verifier.Verify("DeriveTestDirectory");
Assert.NotNull(receivedType);
Assert.True(Directory.Exists(receivedTestDirectory));
Assert.True(Directory.Exists(receivedProjectDirectory));
@ -43,7 +41,7 @@ public class NamerTests :
{
var settings = new VerifySettings();
settings.UniqueForRuntimeAndVersion();
return Verify(Namer.RuntimeAndVersion, settings);
return Verifier.Verify(Namer.RuntimeAndVersion, settings);
}
[Fact]
@ -60,11 +58,6 @@ public class NamerTests :
{
var settings = new VerifySettings();
settings.UniqueForAssemblyConfiguration();
return Verify("Foo", settings);
}
public NamerTests(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify("Foo", settings);
}
}

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

@ -7,12 +7,10 @@ using Newtonsoft.Json;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
// Non-nullable field is uninitialized.
#pragma warning disable CS8618
public class SerializationTests :
VerifyBase
public class SerializationTests
{
static SerializationTests()
{
@ -37,7 +35,7 @@ public class SerializationTests :
DateTimeOffsetString = dateTimeOffset.ToString("F"),
};
await Verify(target);
await Verifier.Verify(target);
#endregion
}
@ -57,7 +55,7 @@ public class SerializationTests :
DateTimeOffsetString = dateTimeOffset.AddDays(2).ToString("F"),
};
return Verify(target);
return Verifier.Verify(target);
}
[Fact]
@ -69,7 +67,7 @@ public class SerializationTests :
s.AppendLine("b");
s.AppendLine("c");
});
return Verify("a", settings);
return Verifier.Verify("a", settings);
}
[Fact]
@ -99,7 +97,7 @@ public class SerializationTests :
_.DontIgnoreEmptyCollections();
});
settings.AddScrubber(s => s.Replace("Lane", "Street"));
return Verify(person, settings);
return Verifier.Verify(person, settings);
}
[Fact]
@ -122,7 +120,7 @@ public class SerializationTests :
var settings = new VerifySettings();
settings.AddExtraSettings(_ => { _.TypeNameHandling = TypeNameHandling.All; });
return Verify(person, settings);
return Verifier.Verify(person, settings);
}
public class DateTimeTarget
@ -140,7 +138,7 @@ public class SerializationTests :
{
var target = new DateTimeTarget();
return Verify(target);
return Verifier.Verify(target);
}
[Fact]
@ -148,7 +146,7 @@ public class SerializationTests :
{
var settings = new VerifySettings();
settings.UseExtension("jpg");
await Verify(File.ReadAllBytes("sample.jpg"), settings);
await Verifier.Verify(File.ReadAllBytes("sample.jpg"), settings);
}
[Fact]
@ -164,7 +162,7 @@ public class SerializationTests :
}
};
return Verify(product);
return Verifier.Verify(product);
}
[Fact]
@ -185,7 +183,7 @@ public class SerializationTests :
{
_.ScrubInlineGuids();
});
return Verify(product, settings);
return Verifier.Verify(product, settings);
}
void DontIgnoreEmptyCollections()
@ -227,7 +225,7 @@ public class SerializationTests :
public Task NewLineEscapedInProperty()
{
#region NewLineEscapedInProperty
return Verify(new {Property = "a\r\nb\\nc"});
return Verifier.Verify(new {Property = "a\r\nb\\nc"});
#endregion
}
@ -237,7 +235,7 @@ public class SerializationTests :
#region DisableNewLineEscaping
var settings = new VerifySettings();
settings.DisableNewLineEscaping();
await Verify(new {Property = "a\r\nb\\nc"}, settings);
await Verifier.Verify(new {Property = "a\r\nb\\nc"}, settings);
#endregion
}
@ -285,25 +283,25 @@ public class SerializationTests :
[Fact]
public Task ScrubTempPath()
{
return Verify(Path.GetTempPath().TrimEnd('/', '\\'));
return Verifier.Verify(Path.GetTempPath().TrimEnd('/', '\\'));
}
[Fact]
public Task ScrubCurrentDirectory()
{
return Verify(Environment.CurrentDirectory.TrimEnd('/', '\\'));
return Verifier.Verify(Environment.CurrentDirectory.TrimEnd('/', '\\'));
}
[Fact]
public Task ScrubCodeBaseLocation()
{
return Verify(CodeBaseLocation.CurrentDirectory.TrimEnd('/', '\\'));
return Verifier.Verify(CodeBaseLocation.CurrentDirectory.TrimEnd('/', '\\'));
}
[Fact]
public Task ScrubBaseDirectory()
{
return Verify(AppDomain.CurrentDomain.BaseDirectory!.TrimEnd('/', '\\'));
return Verifier.Verify(AppDomain.CurrentDomain.BaseDirectory!.TrimEnd('/', '\\'));
}
public class TypeTarget
@ -324,7 +322,7 @@ public class SerializationTests :
Dynamic = foo.GetType(),
};
await Verify(target);
await Verifier.Verify(target);
#endregion
}
@ -335,7 +333,7 @@ public class SerializationTests :
{
#region VerifyTuple
await Verify(() => MethodWithNamedTuple());
await Verifier.Verify(() => MethodWithNamedTuple());
#endregion
}
@ -363,7 +361,7 @@ public class SerializationTests :
OtherGuid = Guid.NewGuid(),
};
await Verify(target);
await Verifier.Verify(target);
#endregion
}
@ -372,7 +370,7 @@ public class SerializationTests :
public Task ShouldIgnoreGuidDefaults()
{
var target = new GuidTarget();
return Verify(target);
return Verifier.Verify(target);
}
[Fact]
@ -384,7 +382,7 @@ public class SerializationTests :
GuidNullable = Guid.NewGuid(),
GuidString = Guid.NewGuid().ToString(),
};
return Verify(target);
return Verifier.Verify(target);
}
public class GuidTarget
@ -402,7 +400,7 @@ public class SerializationTests :
{
Property = @"\"
};
return Verify(target);
return Verifier.Verify(target);
}
public class EscapeTarget
@ -417,7 +415,7 @@ public class SerializationTests :
{
NotDate = "1.2.3"
};
return Verify(target);
return Verifier.Verify(target);
}
public class NotDatesTarget
@ -428,7 +426,7 @@ public class SerializationTests :
[Fact]
public Task ShouldScrubDictionaryKey()
{
return Verify(
return Verifier.Verify(
new
{
guid = new Dictionary<Guid, string>
@ -462,7 +460,7 @@ public class SerializationTests :
ReadOnlyCollection = new List<string>(),
Array = new string[] { }
};
return Verify(target);
return Verifier.Verify(target);
}
public class CollectionTarget
@ -486,7 +484,7 @@ public class SerializationTests :
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
var target = new WithExceptionIgnoreMessage();
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -500,7 +498,7 @@ public class SerializationTests :
var expression = Expression.Lambda<Func<Exception, object>>(convert, parameter);
var settings = new VerifySettings();
settings.UniqueForRuntime();
return Verify(expression, settings);
return Verifier.Verify(expression, settings);
}
class WithExceptionIgnoreMessage
@ -512,7 +510,7 @@ public class SerializationTests :
public Task NotImplementedExceptionProp()
{
var target = new WithNotImplementedException();
return Verify(target);
return Verifier.Verify(target);
}
class WithNotImplementedException
@ -541,7 +539,7 @@ public class SerializationTests :
Property = "Include"
}
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -576,7 +574,7 @@ public class SerializationTests :
Property = "Value"
}
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -617,7 +615,7 @@ public class SerializationTests :
Field = "Value",
Property = "Value"
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -645,7 +643,7 @@ public class SerializationTests :
Property = "Value",
PropertyByName = "Value"
};
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -669,7 +667,7 @@ public class SerializationTests :
settings.ModifySerialization(_ => _.IgnoreMembersThatThrow<CustomException>());
var target = new WithCustomException();
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -688,7 +686,7 @@ public class SerializationTests :
}
catch (Exception exception)
{
return Verify(exception);
return Verifier.Verify(exception);
}
}
@ -700,7 +698,7 @@ public class SerializationTests :
var target = new WithException();
return Assert.ThrowsAsync<JsonSerializationException>(() => Verify(target, settings));
return Assert.ThrowsAsync<JsonSerializationException>(() => Verifier.Verify(target, settings));
}
class WithException
@ -716,7 +714,7 @@ public class SerializationTests :
_ => _.IgnoreMembersThatThrow<Exception>(x => x.Message == "Ignore"));
var target = new WithExceptionNotIgnoreMessage();
return Assert.ThrowsAsync<JsonSerializationException>(() => Verify(target, settings));
return Assert.ThrowsAsync<JsonSerializationException>(() => Verifier.Verify(target, settings));
}
class WithExceptionNotIgnoreMessage
@ -728,7 +726,7 @@ public class SerializationTests :
public Task DelegateProp()
{
var target = new WithDelegate();
return Verify(target);
return Verifier.Verify(target);
}
class WithDelegate
@ -745,7 +743,7 @@ public class SerializationTests :
public Task NotSupportedExceptionProp()
{
var target = new WithNotSupportedException();
return Verify(target);
return Verifier.Verify(target);
}
class WithNotSupportedException
@ -765,7 +763,7 @@ public class SerializationTests :
};
var settings = new VerifySettings();
settings.ModifySerialization(_ => { _.IncludeObsoletes(); });
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
#endregion
@ -785,7 +783,7 @@ public class SerializationTests :
ObsoleteProperty = "value1",
OtherProperty = "value2"
};
return Verify(target);
return Verifier.Verify(target);
}
#endregion
@ -794,8 +792,8 @@ public class SerializationTests :
[Fact]
public async Task Tuple()
{
var exception = await Assert.ThrowsAsync<Exception>(() => Verify(() => MethodWithTuple()));
await Verify(exception.Message);
var exception = await Assert.ThrowsAsync<Exception>(() => Verifier.Verify(() => MethodWithTuple()));
await Verifier.Verify(exception.Message);
}
static (bool, string, string) MethodWithTuple()
@ -823,9 +821,4 @@ public class SerializationTests :
#endregion
}
public SerializationTests(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -6,23 +6,16 @@ using Shipwreck.Phash;
using Shipwreck.Phash.Bitmaps;
using Verify;
using VerifyXunit;
using Xunit.Abstractions;
public class ComparerSnippets :
VerifyBase
public class ComparerSnippets
{
public ComparerSnippets(ITestOutputHelper output) :
base(output)
{
}
public async Task InstanceComparer()
{
#region InstanceComparer
var settings = new VerifySettings();
settings.UseComparer(CompareImages);
settings.UseExtension("png");
await Verify("TheImage.png", settings);
await Verifier.Verify("TheImage.png", settings);
#endregion
}
@ -32,7 +25,7 @@ public class ComparerSnippets :
SharedVerifySettings.RegisterComparer(
extension: "png",
compare: CompareImages);
await VerifyFile("TheImage.png");
await Verifier.VerifyFile("TheImage.png");
#endregion
}

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

@ -7,10 +7,8 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class ConverterSnippets :
VerifyBase
public class ConverterSnippets
{
[Fact]
public async Task Type()
@ -47,7 +45,7 @@ public class ConverterSnippets :
#endregion
#region FileConverterTypeVerify
await using var stream = File.OpenRead("sample.tif");
await Verify(Image.FromStream(stream));
await Verifier.Verify(Image.FromStream(stream));
#endregion
}
@ -84,13 +82,8 @@ public class ConverterSnippets :
#endregion
#region FileConverterExtensionVerify
await VerifyFile("sample.tif");
await Verifier.VerifyFile("sample.tif");
#endregion
}
public ConverterSnippets(ITestOutputHelper output) :
base(output)
{
}
}
#endif

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

@ -6,10 +6,8 @@ using DiffEngine;
using Newtonsoft.Json;
using Verify;
using VerifyXunit;
using Xunit.Abstractions;
public class Snippets:
VerifyBase
public class Snippets
{
#region OnHandlers
public async Task OnHandlersSample()
@ -29,7 +27,7 @@ public class Snippets:
Debug.WriteLine(message);
return Task.CompletedTask;
});
await Verify("value", settings);
await Verifier.Verify("value", settings);
}
#endregion
@ -113,9 +111,4 @@ public class Snippets:
#endregion
}
public Snippets(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -5,14 +5,12 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
using Xunit.Sdk;
// Non-nullable field is uninitialized.
#pragma warning disable CS8618
public class Tests :
VerifyBase
public class Tests
{
static Tests()
{
@ -44,7 +42,7 @@ public class Tests :
onVerifyMismatchCalled = true;
return Task.CompletedTask;
});
await Assert.ThrowsAsync<XunitException>(() => Verify("value", settings));
await Assert.ThrowsAsync<XunitException>(() => Verifier.Verify("value", settings));
Assert.False(onFirstVerifyCalled);
Assert.True(onVerifyMismatchCalled);
}
@ -71,7 +69,7 @@ public class Tests :
onVerifyMismatchCalled = true;
return Task.CompletedTask;
});
await Assert.ThrowsAsync<XunitException>(() => Verify("value", settings));
await Assert.ThrowsAsync<XunitException>(() => Verifier.Verify("value", settings));
Assert.True(onFirstVerifyCalled);
Assert.False(onVerifyMismatchCalled);
}
@ -89,31 +87,31 @@ public class Tests :
});
var settings = new VerifySettings();
settings.UseExtension("SettingsArePassed");
await Verify(new MemoryStream(new byte[] {1}), settings);
await Verifier.Verify(new MemoryStream(new byte[] {1}), settings);
Assert.Same(fromGlobal, settings);
}
[Fact]
public async Task ShouldNotIgnoreCase()
{
await Verify("A");
await Verifier.Verify("A");
var settings = new VerifySettings();
settings.DisableClipboard();
settings.DisableDiff();
await Assert.ThrowsAsync<XunitException>(() => Verify("a", settings));
await Assert.ThrowsAsync<XunitException>(() => Verifier.Verify("a", settings));
}
[Fact]
public Task Newlines()
{
return Verify("a\r\nb\nc\rd\r\n");
return Verifier.Verify("a\r\nb\nc\rd\r\n");
}
[Fact]
public Task TaskResult()
{
var target = Task.FromResult("value");
return Verify(target);
return Verifier.Verify(target);
}
static async IAsyncEnumerable<string> AsyncEnumerableMethod()
@ -127,7 +125,7 @@ public class Tests :
[Fact]
public async Task AsyncEnumerable()
{
await Verify(AsyncEnumerableMethod());
await Verifier.Verify(AsyncEnumerableMethod());
}
static async IAsyncEnumerable<DisposableTarget> AsyncEnumerableDisposableMethod(DisposableTarget target)
@ -140,7 +138,7 @@ public class Tests :
public async Task AsyncEnumerableDisposable()
{
var target = new DisposableTarget();
await Verify(AsyncEnumerableDisposableMethod(target));
await Verifier.Verify(AsyncEnumerableDisposableMethod(target));
Assert.True(target.Disposed);
}
@ -154,7 +152,7 @@ public class Tests :
public async Task AsyncEnumerableAsyncDisposable()
{
var target = new AsyncDisposableTarget();
await Verify(AsyncEnumerableAsyncDisposableMethod(target));
await Verifier.Verify(AsyncEnumerableAsyncDisposableMethod(target));
Assert.True(target.AsyncDisposed);
}
@ -163,7 +161,7 @@ public class Tests :
{
var disposableTarget = new AsyncDisposableTarget();
var target = Task.FromResult(disposableTarget);
await Verify(target);
await Verifier.Verify(target);
Assert.True(disposableTarget.AsyncDisposed);
}
@ -193,7 +191,7 @@ public class Tests :
{
var disposableTarget = new DisposableTarget();
var target = Task.FromResult(disposableTarget);
await Verify(target);
await Verifier.Verify(target);
Assert.True(disposableTarget.Disposed);
}
@ -219,7 +217,7 @@ public class Tests :
{
var settings = new VerifySettings();
settings.UseExtension("jpg");
await Verify(File.ReadAllBytesAsync("sample.jpg"), settings);
await Verifier.Verify(File.ReadAllBytesAsync("sample.jpg"), settings);
}
#endif
@ -227,7 +225,7 @@ public class Tests :
[Fact]
public async Task VerifyFilePath()
{
await VerifyFile("sample.txt");
await Verifier.VerifyFile("sample.txt");
Assert.False(FileEx.IsFileLocked("sample.txt"));
}
@ -244,9 +242,4 @@ public class Tests :
// DontScrubDateTimes();
// await Verify(person);
//}
public Tests(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -5,15 +5,13 @@ using MyNamespace;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class TypeNameConverterTests :
VerifyBase
public class TypeNameConverterTests
{
[Fact]
public Task Simple()
{
return Verify(TypeNameConverter.GetName(typeof(string)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(string)));
}
[Fact]
@ -22,79 +20,79 @@ public class TypeNameConverterTests :
var type = typeof(IEnumerable<>)
.GetGenericArguments()
.First();
return Verify(TypeNameConverter.GetName(type));
return Verifier.Verify(TypeNameConverter.GetName(type));
}
[Fact]
public Task Nested()
{
return Verify(TypeNameConverter.GetName(typeof(TargetWithNested)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(TargetWithNested)));
}
[Fact]
public Task Nullable()
{
return Verify(TypeNameConverter.GetName(typeof(int?)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(int?)));
}
[Fact]
public Task Array()
{
return Verify(TypeNameConverter.GetName(typeof(int[])));
return Verifier.Verify(TypeNameConverter.GetName(typeof(int[])));
}
[Fact]
public Task List()
{
return Verify(TypeNameConverter.GetName(typeof(List<TargetWithNamespace>)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(List<TargetWithNamespace>)));
}
[Fact]
public Task Enumerable()
{
return Verify(TypeNameConverter.GetName(typeof(IEnumerable<TargetWithNamespace>)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(IEnumerable<TargetWithNamespace>)));
}
[Fact]
public Task Dynamic()
{
return Verify(TypeNameConverter.GetName(new {Name = "foo"}.GetType()));
return Verifier.Verify(TypeNameConverter.GetName(new {Name = "foo"}.GetType()));
}
[Fact]
public Task RuntimeEnumerable()
{
return Verify(TypeNameConverter.GetName(MethodWithYield().GetType()));
return Verifier.Verify(TypeNameConverter.GetName(MethodWithYield().GetType()));
}
[Fact]
public Task RuntimeEnumerableDynamic()
{
return Verify(TypeNameConverter.GetName(MethodWithYieldDynamic().GetType()));
return Verifier.Verify(TypeNameConverter.GetName(MethodWithYieldDynamic().GetType()));
}
[Fact]
public Task RuntimeEnumerableWithSelect()
{
return Verify(TypeNameConverter.GetName(MethodWithYield().Select(x => x!=null).GetType()));
return Verifier.Verify(TypeNameConverter.GetName(MethodWithYield().Select(x => x!=null).GetType()));
}
[Fact]
public Task RuntimeEnumerableDynamicWithSelect()
{
return Verify(TypeNameConverter.GetName(MethodWithYieldDynamic().Select(x => x!=null).GetType()));
return Verifier.Verify(TypeNameConverter.GetName(MethodWithYieldDynamic().Select(x => x!=null).GetType()));
}
[Fact]
public Task RuntimeEnumerableDynamicWithInnerSelect()
{
return Verify(TypeNameConverter.GetName(MethodWithYield().Select(x => new {X=x.ToString()}).GetType()));
return Verifier.Verify(TypeNameConverter.GetName(MethodWithYield().Select(x => new {X=x.ToString()}).GetType()));
}
[Fact]
public Task EnumerableOfArray()
{
return Verify(TypeNameConverter.GetName(typeof(IEnumerable<TargetWithNamespace[]>)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(IEnumerable<TargetWithNamespace[]>)));
}
static IEnumerable<TargetWithNamespace> MethodWithYield()
@ -110,21 +108,16 @@ public class TypeNameConverterTests :
[Fact]
public Task ListOfArray()
{
return Verify(TypeNameConverter.GetName(typeof(List<TargetWithNamespace[]>)));
return Verifier.Verify(TypeNameConverter.GetName(typeof(List<TargetWithNamespace[]>)));
}
[Fact]
public Task ArrayOfList()
{
return Verify(TypeNameConverter.GetName(typeof(List<TargetWithNamespace>[])));
return Verifier.Verify(TypeNameConverter.GetName(typeof(List<TargetWithNamespace>[])));
}
public class TargetWithNested{}
public TypeNameConverterTests(ITestOutputHelper output) :
base(output)
{
}
}
namespace MyNamespace

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

@ -12,6 +12,8 @@
<Compile Remove="Converters\TypeConverterTests.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fody" Version="6.2.0" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.0" PrivateAssets="all" />
<PackageReference Include="DiffEngine" Version="3.2.2" />
<PackageReference Include="Shipwreck.Phash.Bitmaps" Version="0.5.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />

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

@ -1,12 +1,9 @@
using System;
using System.Linq;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class VerifySettingsTests :
VerifyBase
public class VerifySettingsTests
{
[Fact]
public void DataIsCloned()
@ -25,9 +22,4 @@ public class VerifySettingsTests :
return new MyCloneable();
}
}
public VerifySettingsTests(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" GenerateXsd="false">
<ModuleInit />
</Weavers>

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

@ -0,0 +1,10 @@
using System.Reflection;
using VerifyXunit;
static class ModuleInitializer
{
public static void Initialize()
{
Verifier.SetTestAssembly(Assembly.GetExecutingAssembly());
}
}

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

@ -2,27 +2,24 @@
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
#region ScrubberLevelsSampleXunit
public class ScrubberLevelsSample :
VerifyBase
public class ScrubberLevelsSample
{
VerifySettings classLevelSettings;
public ScrubberLevelsSample(ITestOutputHelper output) :
base(output)
public ScrubberLevelsSample()
{
classLevelSettings = new VerifySettings();
classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
}
[Fact]
public Task Simple()
public Task Usage()
{
var settings = new VerifySettings(classLevelSettings);
settings.AddScrubber(s => s.Replace("Two", "B"));
return Verify("One Two Three", settings);
return Verifier.Verify("One Two Three", settings);
}
static ScrubberLevelsSample()

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

@ -3,16 +3,10 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
#region ScrubbersSampleXunit
public class ScrubbersSample :
VerifyBase
public class ScrubbersSample
{
public ScrubbersSample(ITestOutputHelper output) :
base(output)
{
}
[Fact]
public Task Lines()
{
@ -29,7 +23,7 @@ public class ScrubbersSample :
settings.ScrubLines(removeLine: line => line.Contains("J"));
settings.ScrubLinesContaining("b", "D");
settings.ScrubLinesContaining(StringComparison.Ordinal, "H");
return Verify(
return Verifier.Verify(
settings: settings,
target: @"
LineA
@ -54,7 +48,7 @@ LineJ
var settings = new VerifySettings();
settings.AddScrubber(
input => input.Replace("0x00000000000007D3", "TheRowVersion"));
return Verify(target, settings);
return Verifier.Verify(target, settings);
}
}
#endregion

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

@ -2,10 +2,8 @@
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class CompareToAssert :
VerifyBase
public class CompareToAssert
{
#region TraditionalTest
[Fact]
@ -30,12 +28,7 @@ public class CompareToAssert :
public Task Simple()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
return Verifier.Verify(person);
}
#endregion
public CompareToAssert(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -3,11 +3,9 @@ using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
#region xunitComplexMemberData
public class ComplexParametersSample :
VerifyBase
public class ComplexParametersSample
{
static ComplexParametersSample()
{
@ -19,8 +17,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()
@ -39,10 +38,5 @@ public class ComplexParametersSample :
{
public string Value { get; set; } = null!;
}
public ComplexParametersSample(ITestOutputHelper output) :
base(output)
{
}
}
#endregion

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

@ -2,15 +2,12 @@
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");
@ -21,7 +18,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>
@ -33,7 +30,7 @@ public class ExtensionSample :
[Fact]
public Task SharedClassLevelSettings()
{
return Verify(
return Verifier.Verify(
target: @"{
""fruit"": ""Apple"",
""size"": ""Large"",

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

@ -1,11 +1,9 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class ParametersSample :
VerifyBase
public class ParametersSample
{
#region xunitInlineData
[Theory]
@ -13,7 +11,9 @@ public class ParametersSample :
[InlineData("Value2")]
public Task InlineDataUsage(string arg)
{
return Verify(arg);
var settings = new VerifySettings();
settings.UseParameters(arg);
return Verifier.Verify(arg, settings);
}
#endregion
@ -22,7 +22,9 @@ public class ParametersSample :
[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()
@ -31,9 +33,4 @@ public class ParametersSample :
yield return new object[] {"Value2"};
}
#endregion
public ParametersSample(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -1,22 +1,16 @@
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
#region SampleTestXunit
public class Sample :
VerifyBase
public class Sample
{
[Fact]
public Task Test()
{
var person = ClassBeingTested.FindPerson();
return Verify(person);
return Verifier.Verify(person);
}
public Sample(ITestOutputHelper output) :
base(output)
{
}
}
#endregion

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

@ -2,18 +2,16 @@
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
#region UniqueForSampleXunit
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]
@ -21,7 +19,7 @@ public class UniqueForSample :
{
var settings = new VerifySettings();
settings.UniqueForRuntimeAndVersion();
return Verify("value", settings);
return Verifier.Verify("value", settings);
}
[Fact]
@ -29,12 +27,7 @@ public class UniqueForSample :
{
var settings = new VerifySettings();
settings.UniqueForAssemblyConfiguration();
return Verify("value", settings);
}
public UniqueForSample(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify("value", settings);
}
}
#endregion

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

@ -0,0 +1,15 @@
using System;
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
public class Tests
{
[Theory]
[InlineData("Value1")]
public async Task MissingParameter(string arg)
{
var exception = await Assert.ThrowsAsync<Exception>(() => Verifier.Verify("Foo"));
Assert.Contains("requires parameters", exception.Message);
}
}

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

@ -1,13 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net48</TargetFrameworks>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
</PropertyGroup>
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
<TargetFrameworks>netcoreapp3.1;net48</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Fody" Version="6.2.0" />
<PackageReference Include="ModuleInit.Fody" Version="2.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
@ -18,6 +17,8 @@
<ProjectReference Include="..\Verify.Xunit\Verify.Xunit.csproj" />
<ProjectReference Include="..\Verify\Verify.csproj" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.1" Condition="$(TargetFramework) == 'net48'" />
<Folder Include="Scrubbers\" />
</ItemGroup>
<Import Project="$(ProjectDir)..\Verify\build\Verify.targets" />
</Project>

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

@ -4,13 +4,11 @@ using Newtonsoft.Json;
using Verify;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
// Non-nullable field is uninitialized
#pragma warning disable CS8618
public class VerifyObjectSamples :
VerifyBase
public class VerifyObjectSamples
{
async Task ChangeDefaultsPerVerification(object target)
{
@ -23,7 +21,7 @@ public class VerifyObjectSamples :
_.DontScrubDateTimes();
_.DontIgnoreFalse();
});
await Verify(target, settings);
await Verifier.Verify(target, settings);
#endregion
}
@ -39,7 +37,7 @@ public class VerifyObjectSamples :
var settings = new VerifySettings();
settings.ModifySerialization(_ => _.DontScrubDateTimes());
settings.AddExtraSettings(_ => _.DateFormatHandling = DateFormatHandling.MicrosoftDateFormat);
await Verify(person, settings);
await Verifier.Verify(person, settings);
}
async Task Before()
@ -58,7 +56,7 @@ public class VerifyObjectSamples :
}
};
await Verify(person);
await Verifier.Verify(person);
#endregion
}
@ -78,7 +76,7 @@ public class VerifyObjectSamples :
FamilyName = "Aguirre"
};
await Verify(
await Verifier.Verify(
new
{
person1,
@ -104,7 +102,7 @@ public class VerifyObjectSamples :
}
};
await Verify(person);
await Verifier.Verify(person);
#endregion
}
@ -124,9 +122,4 @@ public class VerifyObjectSamples :
public string Country;
public string Suburb;
}
public VerifyObjectSamples(ITestOutputHelper output) :
base(output)
{
}
}

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

@ -1,19 +1,12 @@
using System.Threading.Tasks;
using VerifyXunit;
using Xunit;
using Xunit.Abstractions;
public class VerifyTextSample :
VerifyBase
public class VerifyTextSample
{
[Fact]
public Task Simple()
{
return Verify("Foo");
}
public VerifyTextSample(ITestOutputHelper output) :
base(output)
{
return Verifier.Verify("Foo");
}
}

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

@ -0,0 +1,36 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Threading;
using Xunit.Sdk;
namespace VerifyXunit
{
[AttributeUsage(AttributeTargets.Class)]
public class InjectInfoAttribute :
BeforeAfterTestAttribute
{
static AsyncLocal<MethodInfo?> local = new AsyncLocal<MethodInfo?>();
public override void Before(MethodInfo info)
{
local.Value = info;
}
public override void After(MethodInfo info)
{
local.Value = null;
}
internal static bool TryGet([NotNullWhen(true)] out MethodInfo? info)
{
info = local.Value;
if (info == null)
{
return false;
}
return true;
}
}
}

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

@ -1,14 +1,9 @@
using Xunit;
using Xunit.Sdk;
using Xunit.Sdk;
static class ModuleInitializer
{
public static void Initialize()
{
InnerVerifier.Init(
message => new XunitException(message),
input => XunitContext.Context.IntOrNext(input),
input => XunitContext.Context.IntOrNext(input),
input => XunitContext.Context.IntOrNext(input));
InnerVerifier.Init(message => new XunitException(message));
}
}

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

@ -0,0 +1,30 @@
using System;
using Verify;
namespace VerifyXunit
{
public static class ParameterSettings
{
public static void UseParameters(this VerifySettings settings, params object[] parameters)
{
Guard.AgainstNull(settings, nameof(settings));
Guard.AgainstNullOrEmpty(parameters, nameof(parameters));
settings.Data["Parameters"] = parameters;
}
internal static object[] GetParameters(this VerifySettings? settings)
{
if (settings == null)
{
return Array.Empty<object>();
}
if (settings.Data.TryGetValue("Parameters", out var data))
{
return (object[]) data;
}
return Array.Empty<object>();
}
}
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше