Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Dec 14, 2024
1 parent 67fb82f commit bed7993
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 72 deletions.
2 changes: 1 addition & 1 deletion docs/combinations.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ Combination serialization can be customized using a Converter.

Inherit from `CombinationResultsConverter` and override the desired members.

The below sample override `BuildPropertyName` to customize the property name. It bypasses the default implementation and hence does not pad columns or use VerifierSettings.GetNameForParameter for key conversion.
The below sample override `BuildPropertyName` to customize the property name. It bypasses the default implementation and hence does not pad columns or use `VerifierSettings.GetNameForParameter` for key conversion.

<!-- snippet: CombinationSample_CustomSerializationConverter -->
<a id='snippet-CombinationSample_CustomSerializationConverter'></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/mdsource/combinations.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Combination serialization can be customized using a Converter.

Inherit from `CombinationResultsConverter` and override the desired members.

The below sample override `BuildPropertyName` to customize the property name. It bypasses the default implementation and hence does not pad columns or use VerifierSettings.GetNameForParameter for key conversion.
The below sample override `BuildPropertyName` to customize the property name. It bypasses the default implementation and hence does not pad columns or use `VerifierSettings.GetNameForParameter` for key conversion.

snippet: CombinationSample_CustomSerializationConverter

Expand Down
1 change: 1 addition & 0 deletions docs/mdsource/name-for-parameters.include.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
For unknown types the parameter information cannot be derived. In these scenarios `ToString()` is used. To use custom text for a parameter use `NameForParameter()`.
7 changes: 7 additions & 0 deletions docs/mdsource/parameterised-nunit.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ Produces:
* `TestFixtureSourceUsage.Test_arg1=Value2_arg2=2.verified.txt`


### Unknown parameter types

include: name-for-parameters

snippet: NameForParametersNunit


## Overriding text used for parameters

include: override-parameters-text
Expand Down
12 changes: 5 additions & 7 deletions docs/mdsource/parameterised-xunitv2.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,21 @@ Given the following MemberData
snippet: MemberDataGetDataXunit


#### Instance
#### Instance

snippet: MemberDataInstanceXunit


#### Fluent
#### Fluent

snippet: MemberDataFluentXunit


### Complex MemberData

xUnit only exposes parameter information for certain types. For unknown types the information cannot be retrieved from the xUnit context, and instead the text for the parameter value needs to be explicitly specified. This is done by calling `NameForParameter()`.
### Unknown parameter types

snippet: ComplexMemberDataXunit
include: name-for-parameters

`VerifierSettings.NameForParameter()` is required since the parameter type has no `ToString()` override that can be used for deriving the name of the `.verified.` file.
snippet: NameForParametersXunit


## Overriding text used for parameters
Expand Down
8 changes: 3 additions & 5 deletions docs/mdsource/parameterised-xunitv3.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ snippet: InlineDataXunitV3
snippet: MemberDataXunitV3


### Complex MemberData
### Unknown parameter types

xUnit only exposes parameter information for certain types. For unknown types the information cannot be retrieved from the xUnit context, and instead the text for the parameter value needs to be explicitly specified. This is done by calling `NameForParameter()`.
include: name-for-parameters

snippet: xunitV3ComplexMemberData

`VerifierSettings.NameForParameter()` is required since the parameter type has no `ToString()` override that can be used for deriving the name of the `.verified.` file.
snippet: NameForParametersXunitV3


## Overriding text used for parameters
Expand Down
36 changes: 36 additions & 0 deletions docs/parameterised-nunit.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,42 @@ Produces:
* `TestFixtureSourceUsage.Test_arg1=Value2_arg2=2.verified.txt`


### Unknown parameter types

For unknown types the parameter information cannot be derived. In these scenarios `ToString()` is used. To use custom text for a parameter use `NameForParameter()`.<!-- singleLineInclude: name-for-parameters. path: /docs/mdsource/name-for-parameters.include.md -->

<!-- snippet: NameForParametersNunit -->
<a id='snippet-NameForParametersNunit'></a>
```cs
public class ComplexParametersSample
{
[ModuleInitializer]
public static void Initialize() =>
VerifierSettings.NameForParameter<ComplexData>(_ => _.Value);

[TestCaseSource(nameof(GetData))]
public Task ComplexTestCaseSource(ComplexData arg) =>
Verify(arg);

public static IEnumerable<object[]> GetData()
{
yield return
[
new ComplexData("Value1")
];
yield return
[
new ComplexData("Value2")
];
}

public record ComplexData(string Value);
}
```
<sup><a href='/src/Verify.NUnit.Tests/Snippets/ComplexParametersSample.cs#L1-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-NameForParametersNunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


## Overriding text used for parameters

`UseTextForParameters()` can be used to override the substitution text used for the `{Parameters}` part of the file convention.<!-- include: override-parameters-text. path: /docs/mdsource/override-parameters-text.include.md -->
Expand Down
36 changes: 17 additions & 19 deletions docs/parameterised-xunitv2.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static IEnumerable<object[]> GetData()
<!-- endSnippet -->


#### Instance
#### Instance

<!-- snippet: MemberDataInstanceXunit -->
<a id='snippet-MemberDataInstanceXunit'></a>
Expand All @@ -134,7 +134,7 @@ public Task MemberDataUsage(string arg)
<!-- endSnippet -->


#### Fluent
#### Fluent

<!-- snippet: MemberDataFluentXunit -->
<a id='snippet-MemberDataFluentXunit'></a>
Expand All @@ -149,12 +149,12 @@ public Task MemberDataUsageFluent(string arg) =>
<!-- endSnippet -->


### Complex MemberData
### Unknown parameter types

xUnit only exposes parameter information for certain types. For unknown types the information cannot be retrieved from the xUnit context, and instead the text for the parameter value needs to be explicitly specified. This is done by calling `NameForParameter()`.
For unknown types the parameter information cannot be derived. In these scenarios `ToString()` is used. To use custom text for a parameter use `NameForParameter()`.<!-- singleLineInclude: name-for-parameters. path: /docs/mdsource/name-for-parameters.include.md -->

<!-- snippet: ComplexMemberDataXunit -->
<a id='snippet-ComplexMemberDataXunit'></a>
<!-- snippet: NameForParametersXunit -->
<a id='snippet-NameForParametersXunit'></a>
```cs
public class ComplexParametersSample
{
Expand All @@ -166,7 +166,7 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberData(ComplexData arg)
{
var settings = new VerifySettings();
Expand All @@ -175,13 +175,13 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberDataFluent(ComplexData arg) =>
Verify(arg)
.UseParameters(arg);

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberNullableData(ComplexData arg)
{
var settings = new VerifySettings();
Expand All @@ -190,12 +190,12 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberNullableDataFluent(ComplexData arg) =>
Verify(arg)
.UseParameters(arg);

public static IEnumerable<object[]> GetComplexMemberData()
public static IEnumerable<object[]> GetData()
{
yield return
[
Expand All @@ -210,7 +210,7 @@ public class ComplexParametersSample
public record ComplexData(string Value);

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberStructData(ComplexStructData arg)
{
var settings = new VerifySettings();
Expand All @@ -219,13 +219,13 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberStructDataFluent(ComplexStructData arg) =>
Verify(arg)
.UseParameters(arg);

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberNullableStructData(ComplexStructData arg)
{
var settings = new VerifySettings();
Expand All @@ -234,12 +234,12 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberNullableStructDataFluent(ComplexStructData arg) =>
Verify(arg)
.UseParameters(arg);

public static IEnumerable<object[]> GetComplexMemberStructData()
public static IEnumerable<object[]> GetStructData()
{
yield return [new ComplexStructData("Value1")];
yield return [new ComplexStructData("Value2")];
Expand All @@ -248,11 +248,9 @@ public class ComplexParametersSample
public record ComplexStructData(string Value);
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L1-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-ComplexMemberDataXunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/ComplexParametersSample.cs#L1-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-NameForParametersXunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

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


## Overriding text used for parameters

Expand Down
32 changes: 15 additions & 17 deletions docs/parameterised-xunitv3.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public static IEnumerable<object[]> GetData()
<!-- endSnippet -->


### Complex MemberData
### Unknown parameter types

xUnit only exposes parameter information for certain types. For unknown types the information cannot be retrieved from the xUnit context, and instead the text for the parameter value needs to be explicitly specified. This is done by calling `NameForParameter()`.
For unknown types the parameter information cannot be derived. In these scenarios `ToString()` is used. To use custom text for a parameter use `NameForParameter()`.<!-- singleLineInclude: name-for-parameters. path: /docs/mdsource/name-for-parameters.include.md -->

<!-- snippet: xunitV3ComplexMemberData -->
<a id='snippet-xunitV3ComplexMemberData'></a>
<!-- snippet: NameForParametersXunitV3 -->
<a id='snippet-NameForParametersXunitV3'></a>
```cs
public class ComplexParametersSample
{
Expand All @@ -113,7 +113,7 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberData(ComplexData arg)
{
var settings = new VerifySettings();
Expand All @@ -122,13 +122,13 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberDataFluent(ComplexData arg) =>
Verify(arg)
.UseParameters(arg);

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberNullableData(ComplexData arg)
{
var settings = new VerifySettings();
Expand All @@ -137,12 +137,12 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberData))]
[MemberData(nameof(GetData))]
public Task ComplexMemberNullableDataFluent(ComplexData arg) =>
Verify(arg)
.UseParameters(arg);

public static IEnumerable<object[]> GetComplexMemberData()
public static IEnumerable<object[]> GetData()
{
yield return
[
Expand All @@ -157,7 +157,7 @@ public class ComplexParametersSample
public record ComplexData(string Value);

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberStructData(ComplexStructData arg)
{
var settings = new VerifySettings();
Expand All @@ -166,13 +166,13 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberStructDataFluent(ComplexStructData arg) =>
Verify(arg)
.UseParameters(arg);

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberNullableStructData(ComplexStructData arg)
{
var settings = new VerifySettings();
Expand All @@ -181,12 +181,12 @@ public class ComplexParametersSample
}

[Theory]
[MemberData(nameof(GetComplexMemberStructData))]
[MemberData(nameof(GetStructData))]
public Task ComplexMemberNullableStructDataFluent(ComplexStructData arg) =>
Verify(arg)
.UseParameters(arg);

public static IEnumerable<object[]> GetComplexMemberStructData()
public static IEnumerable<object[]> GetStructData()
{
yield return [new ComplexStructData("Value1")];
yield return [new ComplexStructData("Value2")];
Expand All @@ -195,11 +195,9 @@ public class ComplexParametersSample
public record ComplexStructData(string Value);
}
```
<sup><a href='/src/Verify.XunitV3.Tests/Snippets/ComplexParametersSample.cs#L1-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-xunitV3ComplexMemberData' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.XunitV3.Tests/Snippets/ComplexParametersSample.cs#L1-L95' title='Snippet source file'>snippet source</a> | <a href='#snippet-NameForParametersXunitV3' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

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


## Overriding text used for parameters

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
Value: Value1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
Value: Value2
}
Loading

0 comments on commit bed7993

Please sign in to comment.