Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Params docs #1317

Merged
merged 4 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
.
  • Loading branch information
SimonCropp committed Oct 12, 2024
commit d65ef79eafca7e537d2c772079a9315674f197a1
6 changes: 3 additions & 3 deletions docs/explicit-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public Task WithTargets() =>

## MsTest

<!-- snippet: ExplicitTargetsMsTest -->
<a id='snippet-ExplicitTargetsMsTest'></a>
<!-- snippet: ExplicitTargetsMSTest -->
<a id='snippet-ExplicitTargetsMSTest'></a>
```cs
[TestMethod]
public Task WithTargets() =>
Expand All @@ -100,7 +100,7 @@ public Task WithTargets() =>
name: "targetName")
]);
```
<sup><a href='/src/Verify.MSTest.Tests/Tests.cs#L136-L153' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExplicitTargetsMsTest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Tests.cs#L130-L147' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExplicitTargetsMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
2 changes: 1 addition & 1 deletion docs/mdsource/explicit-targets.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ snippet: ExplicitTargetsFixie

## MsTest

snippet: ExplicitTargetsMsTest
snippet: ExplicitTargetsMSTest


## TUnit
Expand Down
8 changes: 4 additions & 4 deletions docs/mdsource/parameterised-mstest.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ include: ignore-parameters

### Instance

snippet: IgnoreParametersForVerifiedMsTest
snippet: IgnoreParametersForVerifiedMSTest


### Fluent

snippet: IgnoreParametersForVerifiedFluentMsTest
snippet: IgnoreParametersForVerifiedFluentMSTest


## IgnoreParametersForVerified with override parameters
Expand All @@ -51,12 +51,12 @@ The parameters passed to IgnoreParametersForVerified can be used pass custom par

### Instance

snippet: IgnoreParametersForVerifiedCustomParamsMsTest
snippet: IgnoreParametersForVerifiedCustomParamsMSTest


### Fluent

snippet: IgnoreParametersForVerifiedCustomParamsFluentMsTest
snippet: IgnoreParametersForVerifiedCustomParamsFluentMSTest


## Hashing parameters
Expand Down
2 changes: 1 addition & 1 deletion docs/mdsource/parameterised-nunit.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Verify.NUnit automatically detects the method parameters. So `UseParameters()` i

If not all parameters are required, a subset can be passed in. In this scenario, the parameters passed in will match with the method parameter names from the start. For example the following will result in a file named `ParametersSample.UseParametersSubSet_arg1=Value1_arg2=Value2.verified.txt`

snippet: UseParametersSubSet
snippet: UseParametersSubSetNunit

If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.

Expand Down
8 changes: 4 additions & 4 deletions docs/mdsource/parameterised-tunit.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ Verify.TUnit automatically detects the method parameters. So `UseParameters()` i

For the above scenarios where parameters are not automatically detected:

snippet: UseParameters
snippet: UseParametersTUnit

If not all parameters are required, a subset can be passed in. In this scenario, the parameters passed in will match with the method parameter names from the start. For example the following will result in a file named `ParametersSample.UseParametersSubSet_arg1=Value1_arg2=Value2.verified.txt`

snippet: UseParametersSubSet
snippet: UseParametersSubSetTUnit

If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.


### TestCase

snippet: TUnitTestCase
snippet: TestCaseTUnit


## Overriding text used for parameters

include: override-parameters-text


snippet: UseTextForParameters
snippet: UseTextForParametersTUnit


## Ignore parameters for verified filename
Expand Down
12 changes: 6 additions & 6 deletions docs/mdsource/parameterised-xunit.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ Verify.Xunit does not detect the parametrised arguments, as such `UseParameters(

For the above scenarios where parameters are not automatically detected:

snippet: UseParameters
snippet: UseParametersXunit

If not all parameters are required, a subset can be passed in. In this scenario, the parameters passed in will match with the method parameter names from the start. For example the following will result in a file named `ParametersSample.UseParametersSubSet_arg1=Value1_arg2=Value2.verified.txt`

snippet: UseParametersSubSet
snippet: UseParametersSubSetXunit

If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.


### InlineData

snippet: xunitInlineData
snippet: InlineDataXunit


### MemberData

snippet: xunitMemberData
snippet: MemberDataXunit


### 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()`.

snippet: xunitComplexMemberData
snippet: ComplexMemberDataXunit

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

Expand All @@ -44,7 +44,7 @@ snippet: xunitComplexMemberData

include: override-parameters-text

snippet: UseTextForParameters
snippet: UseTextForParametersXunit


## Ignore parameters for verified filename
Expand Down
14 changes: 7 additions & 7 deletions docs/mdsource/parameterised-xunitv3.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ Verify.XunitV3 Automatically detect the method parameters for built in types (st

For the above scenarios where parameters are not automatically detected:

snippet: UseParameters
snippet: UseParametersXunitV3

If not all parameters are required, a subset can be passed in. In this scenario, the parameters passed in will match with the method parameter names from the start. For example the following will result in a file named `ParametersSample.UseParametersSubSet_arg1=Value1_arg2=Value2.verified.txt`

snippet: UseParametersSubSet
snippet: UseParametersSubSetXunitV3

If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.


### InlineData

snippet: xunitV3InlineData
snippet: InlineDataXunitV3


### MemberData

snippet: xunitV3MemberData
snippet: MemberDataXunitV3


### Complex MemberData
Expand All @@ -44,7 +44,7 @@ snippet: xunitV3ComplexMemberData

include: override-parameters-text

snippet: UseTextForParameters
snippet: UseTextForParametersXunitV3


## Ignore parameters for verified filename
Expand All @@ -54,7 +54,7 @@ include: ignore-parameters

### Instance

snippet: IgnoreParametersForVerifiedXunit
snippet: IgnoreParametersForVerifiedXunitV3


### Fluent
Expand All @@ -81,4 +81,4 @@ snippet: IgnoreParametersForVerifiedCustomParamsFluentXunit

include: hashing-parameters

snippet: UseParametersHashXunit
snippet: UseParametersHashXunitV3
77 changes: 34 additions & 43 deletions docs/parameterised-mstest.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,46 @@ To change this file edit the source file and then run MarkdownSnippets.

Verify.MSTest does not detect the parametrised arguments, as such `UseParameters()` is required.

<!-- snippet: UseParametersFixie -->
<a id='snippet-UseParametersFixie'></a>
<!-- snippet: UseParametersMSTest -->
<a id='snippet-UseParametersMSTest'></a>
```cs
[TestCase("Value1")]
[TestCase("Value2")]
[DataTestMethod]
[DataRow("Value1")]
[DataRow("Value2")]
public Task UseParametersUsage(string arg)
{
var somethingToVerify = $"{arg} some text";
return Verify(somethingToVerify)
.UseParameters(arg);
}
```
<sup><a href='/src/Verify.Fixie.Tests/Snippets/ParametersSample.cs#L19-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersFixie' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L127-L139' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

If not all parameters are required, a subset can be passed in. In this scenario, the parameters passed in will match with the method parameter names from the start. For example the following will result in a file named `ParametersSample.UseParametersSubSet_arg1=Value1_arg2=Value2.verified.txt`

<!-- snippet: UseParametersSubSetFixie -->
<a id='snippet-UseParametersSubSetFixie'></a>
<!-- snippet: UseParametersSubSetMSTest -->
<a id='snippet-UseParametersSubSetMSTest'></a>
```cs
[TestCase("Value1", "Value2", "Value3")]
[DataTestMethod]
[DataRow("Value1", "Value2", "Value3")]
public Task UseParametersSubSet(string arg1, string arg2, string arg3)
{
var somethingToVerify = $"{arg1} {arg2} {arg3} some text";
return Verify(somethingToVerify)
.UseParameters(arg1, arg2);
}
```
<sup><a href='/src/Verify.Fixie.Tests/Snippets/ParametersSample.cs#L51-L61' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersSubSetFixie' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L141-L152' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseParametersSubSetMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.


### DataRow

<!-- snippet: MSTestDataRow -->
<a id='snippet-MSTestDataRow'></a>
<!-- snippet: DataRowMSTest -->
<a id='snippet-DataRowMSTest'></a>
```cs
[DataTestMethod]
[DataRow("Value1")]
Expand All @@ -70,7 +72,7 @@ public Task DataRowUsageFluent(string arg) =>
Verify(arg)
.UseParameters(arg);
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L4-L23' title='Snippet source file'>snippet source</a> | <a href='#snippet-MSTestDataRow' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L14-L33' title='Snippet source file'>snippet source</a> | <a href='#snippet-DataRowMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -95,27 +97,16 @@ For the fluent case:
* TheTest.UseTextForParametersFluent_Value2.verified.txt<!-- endInclude -->


<!-- snippet: UseTextForParameters -->
<a id='snippet-UseTextForParameters'></a>
<!-- snippet: UseTextForParametersMSTest -->
<a id='snippet-UseTextForParametersMSTest'></a>
```cs
[Theory]
[InlineData("Value1")]
[InlineData("Value2")]
public Task UseTextForParameters(string arg)
{
var settings = new VerifySettings();
settings.UseTextForParameters(arg);
return Verify(arg + "UseTextForParameters", settings);
}

[Theory]
[InlineData("Value1")]
[InlineData("Value2")]
public Task UseTextForParametersFluent(string arg) =>
Verify(arg + "UseTextForParametersFluent")
.UseTextForParameters(arg);
[DataTestMethod]
[DataRow("Value1")]
public Task UseTextForParameters(string arg) =>
Verify(arg)
.UseTextForParameters("TextForParameter");
```
<sup><a href='/src/Verify.Tests/Naming/NamerTests.cs#L381-L400' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseTextForParameters' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L4-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseTextForParametersMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -142,8 +133,8 @@ For the fluent case:

### Instance

<!-- snippet: IgnoreParametersForVerifiedMsTest -->
<a id='snippet-IgnoreParametersForVerifiedMsTest'></a>
<!-- snippet: IgnoreParametersForVerifiedMSTest -->
<a id='snippet-IgnoreParametersForVerifiedMSTest'></a>
```cs
[DataTestMethod]
[DataRow("One")]
Expand All @@ -155,14 +146,14 @@ public Task IgnoreParametersForVerified(string arg)
return Verify("value", settings);
}
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L25-L37' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedMsTest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L35-L47' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


### Fluent

<!-- snippet: IgnoreParametersForVerifiedFluentMsTest -->
<a id='snippet-IgnoreParametersForVerifiedFluentMsTest'></a>
<!-- snippet: IgnoreParametersForVerifiedFluentMSTest -->
<a id='snippet-IgnoreParametersForVerifiedFluentMSTest'></a>
```cs
[DataTestMethod]
[DataRow("One")]
Expand All @@ -171,7 +162,7 @@ public Task IgnoreParametersForVerifiedFluent(string arg) =>
Verify("value")
.IgnoreParametersForVerified(arg);
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L39-L48' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedFluentMsTest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L49-L58' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedFluentMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand All @@ -182,8 +173,8 @@ The parameters passed to IgnoreParametersForVerified can be used pass custom par

### Instance

<!-- snippet: IgnoreParametersForVerifiedCustomParamsMsTest -->
<a id='snippet-IgnoreParametersForVerifiedCustomParamsMsTest'></a>
<!-- snippet: IgnoreParametersForVerifiedCustomParamsMSTest -->
<a id='snippet-IgnoreParametersForVerifiedCustomParamsMSTest'></a>
```cs
[DataTestMethod]
[DataRow("One")]
Expand All @@ -195,14 +186,14 @@ public Task IgnoreParametersForVerifiedCustomParams(string arg)
return Verify("value", settings);
}
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L50-L62' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedCustomParamsMsTest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L60-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedCustomParamsMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


### Fluent

<!-- snippet: IgnoreParametersForVerifiedCustomParamsFluentMsTest -->
<a id='snippet-IgnoreParametersForVerifiedCustomParamsFluentMsTest'></a>
<!-- snippet: IgnoreParametersForVerifiedCustomParamsFluentMSTest -->
<a id='snippet-IgnoreParametersForVerifiedCustomParamsFluentMSTest'></a>
```cs
[DataTestMethod]
[DataRow("One")]
Expand All @@ -211,7 +202,7 @@ public Task IgnoreParametersForVerifiedFluentCustomParams(string arg) =>
Verify("value")
.IgnoreParametersForVerified($"Number{arg}");
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L64-L73' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedCustomParamsFluentMsTest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs#L74-L83' title='Snippet source file'>snippet source</a> | <a href='#snippet-IgnoreParametersForVerifiedCustomParamsFluentMSTest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
Loading
Loading