Skip to content

Commit

Permalink
Remove requirement for [UsesVerify] on xunit tests (#1131)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Jan 17, 2024
1 parent 156fd26 commit ab9f931
Show file tree
Hide file tree
Showing 181 changed files with 343 additions and 459 deletions.
2 changes: 1 addition & 1 deletion docs/anonymous-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public Task Anon()
});
}
```
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.cs#L24-L48' title='Snippet source file'>snippet source</a> | <a href='#snippet-anonxunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/VerifyObjectSamples.cs#L23-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-anonxunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
4 changes: 2 additions & 2 deletions docs/append-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Task AppendFile() =>
Verify("Foo", settings)
.AppendFile("sample.png");
```
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L21-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-appendfile' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L20-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-appendfile' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Will result in two files being verified:
Expand All @@ -39,7 +39,7 @@ public Task AppendContentAsFile() =>
Verify("Foo")
.AppendContentAsFile("extra content");
```
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L30-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-appendcontentasfile' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Converters/InstanceFileAppenderTests.cs#L29-L36' title='Snippet source file'>snippet source</a> | <a href='#snippet-appendcontentasfile' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Will result in two files being verified:
Expand Down
4 changes: 2 additions & 2 deletions docs/binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Task StreamWithExtension()
return Verify(stream, "png");
}
```
<sup><a href='/src/Verify.Tests/StreamTests.cs#L92-L101' title='Snippet source file'>snippet source</a> | <a href='#snippet-streamwithextension' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/StreamTests.cs#L91-L100' title='Snippet source file'>snippet source</a> | <a href='#snippet-streamwithextension' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

For a `FileStream` the extension is not required:
Expand All @@ -33,7 +33,7 @@ For a `FileStream` the extension is not required:
public Task FileStream() =>
Verify(File.OpenRead("sample.txt"));
```
<sup><a href='/src/Verify.Tests/StreamTests.cs#L103-L109' title='Snippet source file'>snippet source</a> | <a href='#snippet-filestream' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/StreamTests.cs#L102-L108' title='Snippet source file'>snippet source</a> | <a href='#snippet-filestream' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
4 changes: 2 additions & 2 deletions docs/compared-to-assertion.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void TraditionalTest()
Assert.Equal("USA", person.Address.Country);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L4-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-traditionaltest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L3-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-traditionaltest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -97,7 +97,7 @@ public Task SnapshotTest()
return Verify(person);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L24-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-snapshottest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/CompareToAssert.cs#L23-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-snapshottest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Produces a snapshot file `SnapshotTest.verified.txt`:
Expand Down
6 changes: 3 additions & 3 deletions docs/comparer.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static Task<CompareResult> CompareImages(
return Task.FromResult(result);
}
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L35-L52' title='Snippet source file'>snippet source</a> | <a href='#snippet-imagecomparer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L34-L51' title='Snippet source file'>snippet source</a> | <a href='#snippet-imagecomparer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The returned `CompareResult.NotEqual` takes an optional message that will be rendered in the resulting text displayed to the user on test failure.
Expand All @@ -60,7 +60,7 @@ public Task InstanceComparerFluent() =>
VerifyFile("sample.png")
.UseStreamComparer(CompareImages);
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L6-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-instancecomparer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L5-L20' title='Snippet source file'>snippet source</a> | <a href='#snippet-instancecomparer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -74,7 +74,7 @@ VerifierSettings.RegisterStreamComparer(
compare: CompareImages);
await VerifyFile("TheImage.png");
```
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L25-L32' title='Snippet source file'>snippet source</a> | <a href='#snippet-staticcomparer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ComparerSnippets.cs#L24-L31' title='Snippet source file'>snippet source</a> | <a href='#snippet-staticcomparer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
12 changes: 6 additions & 6 deletions docs/converter.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ VerifierSettings.RegisterFileConverter<Image>(
targets);
});
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L10-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerfileconvertertype' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L9-L42' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerfileconvertertype' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

<!-- snippet: FileConverterTypeVerify -->
Expand All @@ -87,7 +87,7 @@ VerifierSettings.RegisterFileConverter<Image>(
using var stream = File.OpenRead("sample.tif");
await Verify(Image.FromStream(stream));
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L49-L54' title='Snippet source file'>snippet source</a> | <a href='#snippet-fileconvertertypeverify' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L48-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-fileconvertertypeverify' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Note that this sample also uses the optional `canConvert` to ensure that only `Image`s that are tiffs are converted.
Expand All @@ -97,7 +97,7 @@ Note that this sample also uses the optional `canConvert` to ensure that only `I
```cs
canConvert: (target, context) => Equals(target.RawFormat, ImageFormat.Tiff),
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L14-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-convertercanconvert' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L13-L17' title='Snippet source file'>snippet source</a> | <a href='#snippet-convertercanconvert' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -134,15 +134,15 @@ VerifierSettings.RegisterFileConverter(
targets);
});
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L60-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerfileconverterextension' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L59-L87' title='Snippet source file'>snippet source</a> | <a href='#snippet-registerfileconverterextension' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

<!-- snippet: FileConverterExtensionVerify -->
<a id='snippet-fileconverterextensionverify'></a>
```cs
await VerifyFile("sample.tif");
```
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L94-L98' title='Snippet source file'>snippet source</a> | <a href='#snippet-fileconverterextensionverify' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Snippets/ConverterSnippets.cs#L93-L97' title='Snippet source file'>snippet source</a> | <a href='#snippet-fileconverterextensionverify' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -163,7 +163,7 @@ return new(
return Task.CompletedTask;
});
```
<sup><a href='/src/Verify.Tests/Converters/TypeConverterTests.cs#L32-L44' title='Snippet source file'>snippet source</a> | <a href='#snippet-conversionresultwithcleanup' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Converters/TypeConverterTests.cs#L31-L43' title='Snippet source file'>snippet source</a> | <a href='#snippet-conversionresultwithcleanup' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
28 changes: 14 additions & 14 deletions docs/dates.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var target = new DateTimeTarget

await Verify(target);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1057-L1076' title='Snippet source file'>snippet source</a> | <a href='#snippet-date' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1056-L1075' title='Snippet source file'>snippet source</a> | <a href='#snippet-date' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Results in the following:
Expand Down Expand Up @@ -71,7 +71,7 @@ settings.DontScrubDateTimes();

return Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1689-L1701' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1688-L1700' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimes' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -88,7 +88,7 @@ var target = new
return Verify(target)
.DontScrubDateTimes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1707-L1717' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1706-L1716' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -101,7 +101,7 @@ return Verify(target)
public static void ModuleInitializer() =>
VerifierSettings.DontScrubDateTimes();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1775-L1781' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1774-L1780' title='Snippet source file'>snippet source</a> | <a href='#snippet-dontscrubdatetimesglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -125,7 +125,7 @@ settings.DisableDateCounting();

return Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1736-L1748' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecounting' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1735-L1747' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecounting' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -142,7 +142,7 @@ var target = new
return Verify(target)
.DisableDateCounting();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1754-L1764' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecountingfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1753-L1763' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecountingfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -155,7 +155,7 @@ return Verify(target)
public static void ModuleInitializer() =>
VerifierSettings.DisableDateCounting();
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1723-L1729' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecountingglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1722-L1728' title='Snippet source file'>snippet source</a> | <a href='#snippet-disabledatecountingglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -178,7 +178,7 @@ public Task WithExtraDatetimeFormat() =>
date = "2022-11-08"
});
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L147-L161' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextradatetimeformat' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L146-L160' title='Snippet source file'>snippet source</a> | <a href='#snippet-addextradatetimeformat' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -202,7 +202,7 @@ public Task ScrubInlineDateTimesInstance()
settings);
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1659-L1671' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesinstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1658-L1670' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesinstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -216,7 +216,7 @@ public Task ScrubInlineDateTimesFluent() =>
Verify("content 2020-10-20 content")
.ScrubInlineDateTimes("yyyy-MM-dd");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1650-L1657' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1649-L1656' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -232,7 +232,7 @@ public static class ModuleInitializer
VerifierSettings.ScrubInlineDateTimes("yyyy-MM-dd");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1638-L1647' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1637-L1646' title='Snippet source file'>snippet source</a> | <a href='#snippet-scrubinlinedatetimesglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -253,7 +253,7 @@ settings.AddNamedDateTime(new(2030, 1, 2), "instanceNamedDateTime");
settings.AddNamedDateTimeOffset(new DateTime(2030, 1, 2), "instanceNamedTimeOffset");
await Verify(target, settings);
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1239-L1248' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesinstance' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1238-L1247' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesinstance' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -268,7 +268,7 @@ await Verify(target)
.AddNamedDateTime(new(2030, 1, 2), "instanceNamedDateTime")
.AddNamedDateTimeOffset(new DateTime(2030, 1, 2), "instanceNamedTimeOffset");
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1196-L1204' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesfluent' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1195-L1203' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesfluent' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -286,5 +286,5 @@ public static void NamedDatesAndTimesGlobal()
VerifierSettings.AddNamedDateTimeOffset(new(new(2030, 1, 1)), "namedDateTimeOffset");
}
```
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1151-L1162' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesglobal' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/Serialization/SerializationTests.cs#L1150-L1161' title='Snippet source file'>snippet source</a> | <a href='#snippet-nameddatesandtimesglobal' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
2 changes: 1 addition & 1 deletion docs/explicit-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Task WithTargets() =>
name: "targetName")
});
```
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L44-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-explicittargetsxunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Tests.cs#L43-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-explicittargetsxunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
7 changes: 3 additions & 4 deletions docs/fsharp.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ By default [DefaultValueHandling is Ignore](/docs/serializer-settings.md#default
```fs
VerifierSettings.AddExtraSettings(fun settings -> settings.NullValueHandling <- NullValueHandling.Include)
```
<sup><a href='/src/FSharpTests/Tests.fs#L9-L11' title='Snippet source file'>snippet source</a> | <a href='#snippet-nullvaluehandling' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/FSharpTests/Tests.fs#L8-L10' title='Snippet source file'>snippet source</a> | <a href='#snippet-nullvaluehandling' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -40,7 +40,7 @@ F# does not respect implicit operator conversion. `SettingsTask` uses implicit o
let MyTest () =
Verifier.Verify(15).ToTask() |> Async.AwaitTask
```
<sup><a href='/src/FSharpTests/Tests.fs#L13-L17' title='Snippet source file'>snippet source</a> | <a href='#snippet-fstest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/FSharpTests/Tests.fs#L12-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-fstest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -49,7 +49,6 @@ let MyTest () =
<!-- snippet: FSharpTests/Tests.fs -->
<a id='snippet-FSharpTests/Tests.fs'></a>
```fs
[<VerifyXunit.UsesVerify>]
module Tests
open Xunit
Expand All @@ -72,5 +71,5 @@ let WithFluentSetting () =
|> Async.AwaitTask
do ()
```
<sup><a href='/src/FSharpTests/Tests.fs#L1-L22' title='Snippet source file'>snippet source</a> | <a href='#snippet-FSharpTests/Tests.fs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/FSharpTests/Tests.fs#L1-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-FSharpTests/Tests.fs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Loading

0 comments on commit ab9f931

Please sign in to comment.