Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Oct 25, 2024
1 parent f6fbec7 commit c6707a9
Show file tree
Hide file tree
Showing 30 changed files with 135 additions and 193 deletions.
82 changes: 51 additions & 31 deletions docs/combinations.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static string BuildAddress(int streetNumber, string street, string city)
return $"{streetNumber} {street}, {city}";
}
```
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.cs#L6-L17' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationTargetMethod' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.cs#L5-L16' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationTargetMethod' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -47,7 +47,7 @@ public Task BuildAddressTest()
cities);
}
```
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.cs#L19-L34' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.cs#L18-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -104,7 +104,7 @@ public Task BuildAddressExceptionsTest()
captureExceptions: true);
}
```
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.cs#L53-L69' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CaptureExceptions' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.cs#L52-L68' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CaptureExceptions' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -114,31 +114,27 @@ public Task BuildAddressExceptionsTest()
<a id='snippet-VerifyCombinationsSample.BuildAddressExceptionsTest.verified.txt'></a>
```txt
{
-1, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
-1, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
-1, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
-1, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
-1, Valid St, null : ArgumentNullException: Value cannot be null. (Parameter 'city'),
-1, Valid St, Valid City:
ArgumentOutOfRangeException: streetNumber ('-1') must be greater than or equal to '1'. (Parameter 'streetNumber')
Actual value was -1.,
0, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
0, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
0, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
0, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
0, Valid St, null : ArgumentNullException: Value cannot be null. (Parameter 'city'),
0, Valid St, Valid City:
ArgumentOutOfRangeException: streetNumber ('0') must be greater than or equal to '1'. (Parameter 'streetNumber')
Actual value was 0.,
10, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
10, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
10, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
10, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street'),
10, Valid St, null : ArgumentNullException: Value cannot be null. (Parameter 'city'),
-1, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
-1, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
-1, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
-1, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
-1, Valid St, null : ArgumentNullException: Value cannot be null. (Parameter 'city').,
-1, Valid St, Valid City: ArgumentOutOfRangeException: streetNumber ('-1') must be greater than or equal to '1'. (Parameter 'streetNumber'). Actual value was -1.,
0, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
0, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
0, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
0, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
0, Valid St, null : ArgumentNullException: Value cannot be null. (Parameter 'city').,
0, Valid St, Valid City: ArgumentOutOfRangeException: streetNumber ('0') must be greater than or equal to '1'. (Parameter 'streetNumber'). Actual value was 0.,
10, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
10, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
10, , null : ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
10, , Valid City: ArgumentException: The value cannot be an empty string or composed entirely of whitespace. (Parameter 'street').,
10, Valid St, null : ArgumentNullException: Value cannot be null. (Parameter 'city').,
10, Valid St, Valid City: 10 Valid St, Valid City
}
```
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.BuildAddressExceptionsTest.verified.txt#L1-L24' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyCombinationsSample.BuildAddressExceptionsTest.verified.txt' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Tests/VerifyCombinationsSample.BuildAddressExceptionsTest.verified.txt#L1-L20' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyCombinationsSample.BuildAddressExceptionsTest.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -153,7 +149,7 @@ Exception capture can be enable globally:
public static void Initialize() =>
VerifyCombinationSettings.CaptureExceptions();
```
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L4-L10' title='Snippet source file'>snippet source</a> | <a href='#snippet-GlobalCaptureExceptions' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L3-L9' title='Snippet source file'>snippet source</a> | <a href='#snippet-GlobalCaptureExceptions' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

If exception capture has been enabled globally, it can be disable at the method test level using `captureExceptions: false`.
Expand All @@ -175,7 +171,7 @@ public Task BuildAddressExceptionsDisabledTest()
captureExceptions: false);
}
```
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L69-L85' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CaptureExceptionsFalse' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L68-L84' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CaptureExceptionsFalse' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -276,11 +272,35 @@ public class CombinationResultsConverter :
return;
}

writer.WriteValue($"{exception.GetType().Name}: {exception.Message}");
var message = exception.Message;
if (exception is ArgumentException)
{
message = FlattenMessage(message);
}

writer.WriteValue($"{exception.GetType().Name}: {message}");
}

static string FlattenMessage(string message)
{
var builder = new StringBuilder();

foreach (var line in message.AsSpan().EnumerateLines())
{
var trimmed = line.TrimEnd();
builder.Append(trimmed);
if (!trimmed.EndsWith('.'))
{
builder.Append(". ");
}
}

builder.TrimEnd();
return builder.ToString();
}
}
```
<sup><a href='/src/Verify/Combinations/CombinationResultsConverter.cs#L1-L93' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationResultsConverter.cs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify/Combinations/CombinationResultsConverter.cs#L1-L117' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationResultsConverter.cs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -306,7 +326,7 @@ class CustomCombinationConverter :
string.Join(", ", keys.Select(_ => _.Value));
}
```
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L114-L124' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CustomSerializationConverter' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L113-L123' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CustomSerializationConverter' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Full control of serialization can be achieved by inheriting from `WriteOnlyJsonConverter<CombinationResults>`.
Expand All @@ -325,7 +345,7 @@ static CustomCombinationConverter customConverter = new();
public static void Init() =>
VerifierSettings.AddExtraSettings(_ => _.Converters.Insert(0, customConverter));
```
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L87-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CustomSerializationModuleInitializer' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/StaticSettingsTests/VerifyCombinationsTests.cs#L86-L94' title='Snippet source file'>snippet source</a> | <a href='#snippet-CombinationSample_CustomSerializationModuleInitializer' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget</NoWarn>
<Version>27.1.0-beta.2</Version>
<Version>27.1.0</Version>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
A: a,
b: ArgumentException: B is not allowed,
b: ArgumentException: B is not allowed.,
C: c
}
3 changes: 1 addition & 2 deletions src/StaticSettingsTests/VerifyCombinationsTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma warning disable VerifyCombinations
public class VerifyCombinationsTests
public class VerifyCombinationsTests
{
#region GlobalCaptureExceptions

Expand Down
3 changes: 1 addition & 2 deletions src/Verify.Fixie.Tests/VerifyCombinationsTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma warning disable VerifyCombinations
public class VerifyCombinationsTests
public class VerifyCombinationsTests
{
public Task One()
{
Expand Down
9 changes: 0 additions & 9 deletions src/Verify.Fixie/Verifier_Combination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace VerifyFixie;
public static partial class Verifier
{
[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A>(
Func<A, object?> method,
IEnumerable<A> a,
Expand All @@ -17,7 +16,6 @@ public static SettingsTask VerifyCombinations<A>(
_ => _.VerifyCombinations(method, captureExceptions, a));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B>(
Func<A, B, object?> method,
IEnumerable<A> a,
Expand All @@ -31,7 +29,6 @@ public static SettingsTask VerifyCombinations<A, B>(
_ => _.VerifyCombinations(method, captureExceptions, a, b));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C>(
Func<A, B, C, object?> method,
IEnumerable<A> a,
Expand All @@ -46,7 +43,6 @@ public static SettingsTask VerifyCombinations<A, B, C>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D>(
Func<A, B, C, D, object?> method,
IEnumerable<A> a,
Expand All @@ -62,7 +58,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E>(
Func<A, B, C, D, E, object?> method,
IEnumerable<A> a,
Expand All @@ -79,7 +74,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E, F>(
Func<A, B, C, D, E, F, object?> method,
IEnumerable<A> a,
Expand All @@ -97,7 +91,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E, F>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e, f));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G>(
Func<A, B, C, D, E, F, G, object?> method,
IEnumerable<A> a,
Expand All @@ -116,7 +109,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e, f, g));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G, H>(
Func<A, B, C, D, E, F, G, H, object?> method,
IEnumerable<A> a,
Expand All @@ -136,7 +128,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G, H>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e, f, g, h));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations(
Func<object?[], object?> method,
List<IEnumerable<object?>> lists,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
A, 2, False: a2False,
A, 3, True : a3True,
A, 3, False: a3False,
b, 1, True : ArgumentException: B is not allowed,
b, 1, False: ArgumentException: B is not allowed,
b, 2, True : ArgumentException: B is not allowed,
b, 2, False: ArgumentException: B is not allowed,
b, 3, True : ArgumentException: B is not allowed,
b, 3, False: ArgumentException: B is not allowed,
b, 1, True : ArgumentException: B is not allowed.,
b, 1, False: ArgumentException: B is not allowed.,
b, 2, True : ArgumentException: B is not allowed.,
b, 2, False: ArgumentException: B is not allowed.,
b, 3, True : ArgumentException: B is not allowed.,
b, 3, False: ArgumentException: B is not allowed.,
C, 1, True : c1True,
C, 1, False: c1False,
C, 2, True : c2True,
Expand Down
3 changes: 1 addition & 2 deletions src/Verify.MSTest.Tests/VerifyCombinationsTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#pragma warning disable VerifyCombinations
[TestClass]
[TestClass]
public partial class VerifyCombinationsTests
{
[TestMethod]
Expand Down
9 changes: 0 additions & 9 deletions src/Verify.MSTest/Verifier_Combination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace VerifyMSTest;
public static partial class Verifier
{
[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A>(
Func<A, object?> method,
IEnumerable<A> a,
Expand All @@ -17,7 +16,6 @@ public static SettingsTask VerifyCombinations<A>(
_ => _.VerifyCombinations(method, captureExceptions, a));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B>(
Func<A, B, object?> method,
IEnumerable<A> a,
Expand All @@ -31,7 +29,6 @@ public static SettingsTask VerifyCombinations<A, B>(
_ => _.VerifyCombinations(method, captureExceptions, a, b));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C>(
Func<A, B, C, object?> method,
IEnumerable<A> a,
Expand All @@ -46,7 +43,6 @@ public static SettingsTask VerifyCombinations<A, B, C>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D>(
Func<A, B, C, D, object?> method,
IEnumerable<A> a,
Expand All @@ -62,7 +58,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E>(
Func<A, B, C, D, E, object?> method,
IEnumerable<A> a,
Expand All @@ -79,7 +74,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E, F>(
Func<A, B, C, D, E, F, object?> method,
IEnumerable<A> a,
Expand All @@ -97,7 +91,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E, F>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e, f));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G>(
Func<A, B, C, D, E, F, G, object?> method,
IEnumerable<A> a,
Expand All @@ -116,7 +109,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e, f, g));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G, H>(
Func<A, B, C, D, E, F, G, H, object?> method,
IEnumerable<A> a,
Expand All @@ -136,7 +128,6 @@ public static SettingsTask VerifyCombinations<A, B, C, D, E, F, G, H>(
_ => _.VerifyCombinations(method, captureExceptions, a, b, c, d, e, f, g, h));

[Pure]
[Experimental("VerifyCombinations")]
public static SettingsTask VerifyCombinations(
Func<object?[], object?> method,
List<IEnumerable<object?>> lists,
Expand Down
Loading

0 comments on commit c6707a9

Please sign in to comment.