diff --git a/docs/explicit-targets.md b/docs/explicit-targets.md
index 01e7f000e6..f78650851b 100644
--- a/docs/explicit-targets.md
+++ b/docs/explicit-targets.md
@@ -100,7 +100,7 @@ public Task WithTargets() =>
name: "targetName")
]);
```
-snippet source | anchor
+snippet source | anchor
diff --git a/docs/mdsource/parameterised-mstest.source.md b/docs/mdsource/parameterised-mstest.source.md
index f74c2279e5..19fda35a6e 100644
--- a/docs/mdsource/parameterised-mstest.source.md
+++ b/docs/mdsource/parameterised-mstest.source.md
@@ -5,9 +5,7 @@
`UseParameters()` controls what parameters are used when naming files.
-Verify.MSTest does not detect the parametrised arguments, as such `UseParameters()` is required.
-
-snippet: UseParametersMSTest
+Verify.MSTest automatically detects the method parameters. So `UseParameters()` is not required unless using custom parameters.
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`
@@ -18,22 +16,13 @@ If the number of parameters passed to `UseParameters()` is greater than the numb
### DataRow
-
-#### Instance
-
snippet: DataRowInstanceMSTest
-#### Fluent
-
-snippet: DataRowFluentMSTest
-
-
## Overriding text used for parameters
include: override-parameters-text
-
snippet: UseTextForParametersMSTest
diff --git a/docs/parameterised-mstest.md b/docs/parameterised-mstest.md
index 3308e3ba71..af2420dfc0 100644
--- a/docs/parameterised-mstest.md
+++ b/docs/parameterised-mstest.md
@@ -12,23 +12,7 @@ To change this file edit the source file and then run MarkdownSnippets.
`UseParameters()` controls what parameters are used when naming files.
-Verify.MSTest does not detect the parametrised arguments, as such `UseParameters()` is required.
-
-
-
-```cs
-[DataTestMethod]
-[DataRow("Value1")]
-[DataRow("Value2")]
-public Task UseParametersUsage(string arg)
-{
- var somethingToVerify = $"{arg} some text";
- return Verify(somethingToVerify)
- .UseParameters(arg);
-}
-```
-snippet source | anchor
-
+Verify.MSTest automatically detects the method parameters. So `UseParameters()` is not required unless using custom parameters.
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`
@@ -44,7 +28,7 @@ public Task UseParametersSubSet(string arg1, string arg2, string arg3)
.UseParameters(arg1, arg2);
}
```
-snippet source | anchor
+snippet source | anchor
If the number of parameters passed to `UseParameters()` is greater than the number of parameters in the test method, an exception will be thrown.
@@ -52,39 +36,16 @@ If the number of parameters passed to `UseParameters()` is greater than the numb
### DataRow
-
-#### Instance
-
```cs
[DataTestMethod]
[DataRow("Value1")]
[DataRow("Value2")]
-public Task DataRowUsage(string arg)
-{
- var settings = new VerifySettings();
- settings.UseParameters(arg);
- return Verify(arg, settings);
-}
-```
-snippet source | anchor
-
-
-
-#### Fluent
-
-
-
-```cs
-[DataTestMethod]
-[DataRow("Value1")]
-[DataRow("Value2")]
-public Task DataRowUsageFluent(string arg) =>
- Verify(arg)
- .UseParameters(arg);
+public Task DataRowUsage(string arg) =>
+ Verify(arg);
```
-snippet source | anchor
+snippet source | anchor
@@ -108,7 +69,6 @@ For the fluent case:
* TheTest.UseTextForParametersFluent_Value1.verified.txt
* TheTest.UseTextForParametersFluent_Value2.verified.txt
-
```cs
@@ -158,7 +118,7 @@ public Task IgnoreParametersForVerified(string arg)
return Verify("value", settings);
}
```
-snippet source | anchor
+snippet source | anchor
@@ -174,7 +134,7 @@ public Task IgnoreParametersForVerifiedFluent(string arg) =>
Verify("value")
.IgnoreParametersForVerified(arg);
```
-snippet source | anchor
+snippet source | anchor
@@ -198,7 +158,7 @@ public Task IgnoreParametersForVerifiedCustomParams(string arg)
return Verify("value", settings);
}
```
-snippet source | anchor
+snippet source | anchor
@@ -214,7 +174,7 @@ public Task IgnoreParametersForVerifiedFluentCustomParams(string arg) =>
Verify("value")
.IgnoreParametersForVerified($"Number{arg}");
```
-snippet source | anchor
+snippet source | anchor
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 49211b35ca..a5d600a9b7 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -2,7 +2,7 @@
CA1822;CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget
- 28.6.1
+ 28.7.0
enable
preview
1.0.0
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 930660b8ce..51100da079 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/src/Verify.MSTest.Tests/Snippets/ParametersHashSample.cs b/src/Verify.MSTest.Tests/Snippets/ParametersHashSample.cs
index 48d8472048..888ad855f1 100644
--- a/src/Verify.MSTest.Tests/Snippets/ParametersHashSample.cs
+++ b/src/Verify.MSTest.Tests/Snippets/ParametersHashSample.cs
@@ -9,7 +9,6 @@ public partial class ParametersHashSample
public Task HashParametersUsage(string arg)
{
var settings = new VerifySettings();
- settings.UseParameters(arg);
settings.HashParameters();
return Verify(arg, settings);
}
@@ -19,7 +18,6 @@ public Task HashParametersUsage(string arg)
[DataRow("Value2")]
public Task HashParametersUsageFluent(string arg) =>
Verify(arg)
- .UseParameters(arg)
.HashParameters();
}
diff --git a/src/Verify.MSTest.Tests/Snippets/ParametersSample.DataRowUsageFluent_arg=Value1.verified.txt b/src/Verify.MSTest.Tests/Snippets/ParametersSample.DataRowUsageFluent_arg=Value1.verified.txt
deleted file mode 100644
index 39d0344b5c..0000000000
--- a/src/Verify.MSTest.Tests/Snippets/ParametersSample.DataRowUsageFluent_arg=Value1.verified.txt
+++ /dev/null
@@ -1 +0,0 @@
-Value1
\ No newline at end of file
diff --git a/src/Verify.MSTest.Tests/Snippets/ParametersSample.DataRowUsageFluent_arg=Value2.verified.txt b/src/Verify.MSTest.Tests/Snippets/ParametersSample.DataRowUsageFluent_arg=Value2.verified.txt
deleted file mode 100644
index 3696843c5e..0000000000
--- a/src/Verify.MSTest.Tests/Snippets/ParametersSample.DataRowUsageFluent_arg=Value2.verified.txt
+++ /dev/null
@@ -1 +0,0 @@
-Value2
\ No newline at end of file
diff --git a/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs b/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs
index 448faccc37..793b848afc 100644
--- a/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs
+++ b/src/Verify.MSTest.Tests/Snippets/ParametersSample.cs
@@ -16,23 +16,8 @@ public Task UseTextForParameters(string arg) =>
[DataTestMethod]
[DataRow("Value1")]
[DataRow("Value2")]
- public Task DataRowUsage(string arg)
- {
- var settings = new VerifySettings();
- settings.UseParameters(arg);
- return Verify(arg, settings);
- }
-
- #endregion
-
- #region DataRowFluentMSTest
-
- [DataTestMethod]
- [DataRow("Value1")]
- [DataRow("Value2")]
- public Task DataRowUsageFluent(string arg) =>
- Verify(arg)
- .UseParameters(arg);
+ public Task DataRowUsage(string arg) =>
+ Verify(arg);
#endregion
@@ -94,7 +79,6 @@ public Task IgnoreParametersForVerifiedFluentCustomParams(string arg) =>
public Task IgnoreParameters(string arg)
{
var settings = new VerifySettings();
- settings.UseParameters(arg);
settings.IgnoreParameters(nameof(arg));
return Verify("value", settings);
}
@@ -108,7 +92,6 @@ public Task IgnoreParameters(string arg)
[DataRow("Two")]
public Task IgnoreParametersFluent(string arg) =>
Verify("value")
- .UseParameters(arg)
.IgnoreParameters(nameof(arg));
#endregion
@@ -128,20 +111,6 @@ public Task IgnoreParametersCustomParams(string arg)
#endregion
- #region UseParametersMSTest
-
- [DataTestMethod]
- [DataRow("Value1")]
- [DataRow("Value2")]
- public Task UseParametersUsage(string arg)
- {
- var somethingToVerify = $"{arg} some text";
- return Verify(somethingToVerify)
- .UseParameters(arg);
- }
-
- #endregion
-
#region UseParametersSubSetMSTest
[DataTestMethod]
diff --git a/src/Verify.MSTest.Tests/Snippets/ParametersTests.Float.verified.txt b/src/Verify.MSTest.Tests/Snippets/ParametersTests.Float.verified.txt
new file mode 100644
index 0000000000..5f282702bb
--- /dev/null
+++ b/src/Verify.MSTest.Tests/Snippets/ParametersTests.Float.verified.txt
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/Verify.MSTest.Tests/Snippets/ParametersTests.cs b/src/Verify.MSTest.Tests/Snippets/ParametersTests.cs
index 076bfe5fde..813bd2c950 100644
--- a/src/Verify.MSTest.Tests/Snippets/ParametersTests.cs
+++ b/src/Verify.MSTest.Tests/Snippets/ParametersTests.cs
@@ -5,19 +5,16 @@ public partial class ParametersTests
//[DataRow("1.1")]
//public async Task Decimal(decimal arg)
//{
- // await Verify(arg)
- // .UseParameters(arg);
+ // await Verify(arg);
//}
[DataTestMethod]
[DataRow((float) 1.1)]
public Task Float(float arg) =>
- Verify(arg)
- .UseParameters(arg);
+ Verify(arg);
[DataTestMethod]
[DataRow(1.1d)]
public Task Double(double arg) =>
- Verify(arg)
- .UseParameters(arg);
+ Verify(arg);
}
\ No newline at end of file
diff --git a/src/Verify.MSTest.Tests/Tests.MissingParameter.verified.txt b/src/Verify.MSTest.Tests/Tests.MissingParameter.verified.txt
deleted file mode 100644
index fdf74cdc4b..0000000000
--- a/src/Verify.MSTest.Tests/Tests.MissingParameter.verified.txt
+++ /dev/null
@@ -1 +0,0 @@
-Foo
\ No newline at end of file
diff --git a/src/Verify.MSTest.Tests/Tests.MissingParameter_arg=Value1.verified.txt b/src/Verify.MSTest.Tests/Tests.MissingParameter_arg=Value1.verified.txt
new file mode 100644
index 0000000000..5f282702bb
--- /dev/null
+++ b/src/Verify.MSTest.Tests/Tests.MissingParameter_arg=Value1.verified.txt
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/Verify.MSTest.Tests/Tests.cs b/src/Verify.MSTest.Tests/Tests.cs
index ff8aa30b96..958a0a0f75 100644
--- a/src/Verify.MSTest.Tests/Tests.cs
+++ b/src/Verify.MSTest.Tests/Tests.cs
@@ -20,11 +20,6 @@ static void DerivePathInfo()
#endregion
}
- [DataTestMethod]
- [DataRow("Value1")]
- public Task MissingParameter(string arg) =>
- Verify("Foo");
-
[DataTestMethod]
[DataRow("Value1")]
public Task UseFileNameWithParam(string arg) =>
diff --git a/src/Verify.MSTest/Verifier.cs b/src/Verify.MSTest/Verifier.cs
index 2fca092fab..872eb1a2b8 100644
--- a/src/Verify.MSTest/Verifier.cs
+++ b/src/Verify.MSTest/Verifier.cs
@@ -37,6 +37,15 @@ static InnerVerifier BuildVerifier(VerifySettings settings, string sourceFile, b
var type = context.TestClass;
var method = context.Method;
+ if (!settings.HasParameters)
+ {
+ var data = context.TestContext.TestData;
+ if (data != null)
+ {
+ settings.SetParameters(data);
+ }
+ }
+
VerifierSettings.AssignTargetAssembly(assembly);
var pathInfo = GetPathInfo(sourceFile, type, method);
return new(