diff --git a/docs/parameterised.md b/docs/parameterised.md index b753c53b81..280f3bb58f 100644 --- a/docs/parameterised.md +++ b/docs/parameterised.md @@ -276,17 +276,8 @@ When using a [TestFixtureSource](https://docs.nunit.org/articles/nunit/writing-t ```cs [TestFixtureSource(nameof(FixtureArgs))] -public class TestFixtureSourceUsage +public class TestFixtureSourceUsage(string arg1, int arg2) { - string arg1; - int arg2; - - public TestFixtureSourceUsage(string arg1, int arg2) - { - this.arg1 = arg1; - this.arg2 = arg2; - } - [Test] public Task Test() => Verify( @@ -311,7 +302,7 @@ public class TestFixtureSourceUsage }; } ``` -snippet source | anchor +snippet source | anchor Produces `TestFixtureSourceUsage(Value1,1).Test.verified.txt` and `TestFixtureSourceUsage(Value2,2).Test.verified.txt`. diff --git a/src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs b/src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs index 0cd205975f..d39ae58198 100644 --- a/src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs +++ b/src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs @@ -1,15 +1,6 @@ [TestFixtureSource(nameof(FixtureArgs))] -public class TestFixtureSourceUsage +public class TestFixtureSourceUsage(string arg1, int arg2) { - string arg1; - int arg2; - - public TestFixtureSourceUsage(string arg1, int arg2) - { - this.arg1 = arg1; - this.arg2 = arg2; - } - [Test] public Task Test() => Verify( diff --git a/src/Verify.NUnit.Tests/TestFixtureSourceUsageExtraParameters.cs b/src/Verify.NUnit.Tests/TestFixtureSourceUsageExtraParameters.cs index 4787183ae9..68c4099942 100644 --- a/src/Verify.NUnit.Tests/TestFixtureSourceUsageExtraParameters.cs +++ b/src/Verify.NUnit.Tests/TestFixtureSourceUsageExtraParameters.cs @@ -1,15 +1,6 @@ [TestFixtureSource(nameof(FixtureArgs))] -public class TestFixtureSourceAndTestCaseUsage +public class TestFixtureSourceAndTestCaseUsage(string arg1, int arg2) { - string arg1; - int arg2; - - public TestFixtureSourceAndTestCaseUsage(string arg1, int arg2) - { - this.arg1 = arg1; - this.arg2 = arg2; - } - [TestCase("FromTestCase2")] public Task Test(string arg3) => Verify( diff --git a/src/Verify.NUnit.Tests/TestFixtureSourceUsageWithNamespace.cs b/src/Verify.NUnit.Tests/TestFixtureSourceUsageWithNamespace.cs index 4777eef61e..0f8a18bd1c 100644 --- a/src/Verify.NUnit.Tests/TestFixtureSourceUsageWithNamespace.cs +++ b/src/Verify.NUnit.Tests/TestFixtureSourceUsageWithNamespace.cs @@ -1,17 +1,8 @@ namespace MyNamespace; [TestFixtureSource(nameof(FixtureArgs))] -public class TestFixtureSourceUsageWithNamespace +public class TestFixtureSourceUsageWithNamespace(string arg1, int arg2) { - string arg1; - int arg2; - - public TestFixtureSourceUsageWithNamespace(string arg1, int arg2) - { - this.arg1 = arg1; - this.arg2 = arg2; - } - [Test] public Task Test() => Verify(new diff --git a/src/Verify.Tests/SimpleTypeTests.cs b/src/Verify.Tests/SimpleTypeTests.cs index 2a7a91f1af..2151c66c8f 100644 --- a/src/Verify.Tests/SimpleTypeTests.cs +++ b/src/Verify.Tests/SimpleTypeTests.cs @@ -22,7 +22,7 @@ public Task StringEmptyWrappedInTask() => [Fact] public Task StringNullWrappedInTask() => - Verify(Task.FromResult((string)null!)); + Verify(Task.FromResult((string) null!)); [Fact] public Task StringEmpty() => @@ -30,11 +30,11 @@ public Task StringEmpty() => [Fact] public Task StringNull() => - Verify((string?)null); + Verify((string?) null); [Fact] public Task Null() => - Verify((object?)null); + Verify((object?) null); [Fact] public Task NullWrappedInTask() => @@ -53,52 +53,58 @@ public Task GuidWrappedInTask() => public static IEnumerable GetData() { - yield return new object[] {new KeyValuePair("theKey",10)}; + yield return [new KeyValuePair("theKey", 10)]; var json = """ - { - 'short': { - 'original': 'http://www.foo.com/', - 'short': 'foo', - 'error': { - 'code': 0, - 'msg': 'No action taken' - } - } - } - """; + { + 'short': { + 'original': 'http://www.foo.com/', + 'short': 'foo', + 'error': { + 'code': 0, + 'msg': 'No action taken' + } + } + } + """; var argonJToken = JToken.Parse(json); - yield return new object[] {argonJToken}; + yield return new object[] + { + argonJToken + }; - var jsonArray = """ - [ - 'Small', - 'Medium', - 'Large' - ] - """; - - var argonJArray = JArray.Parse(jsonArray); - yield return new object[] {argonJArray}; - yield return new object[] {true}; - yield return new object[] {"stringValue"}; - yield return new object[] {File.OpenRead("sample.png")}; - yield return new object[] {new byte[]{1}}; - yield return new object[] {(long) 1}; - yield return new object[] {(short) 1}; - yield return new object[] {1}; - yield return new object[] {(uint) 1}; - yield return new object[] {(ulong) 1}; - yield return new object[] {(ushort) 1}; - yield return new object[] {(decimal) 1.1}; - yield return new object[] {(float) 1.1}; - yield return new object[] {new Guid("ebced679-45d3-4653-8791-3d969c4a986c")}; - yield return new object[] {new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc).ToUniversalTime()}; - yield return new object[] {new DateTimeOffset(2000, 1, 1, 1, 1, 1, 1, TimeSpan.FromHours(1)).ToUniversalTime()}; + yield return [ + JArray.Parse( + """ + [ + 'Small', + 'Medium', + 'Large' + ] + """) + ]; + yield return [true]; + yield return ["stringValue"]; + yield return [File.OpenRead("sample.png")]; + yield return [new byte[] + { + 1 + }]; + yield return [(long) 1]; + yield return [(short) 1]; + yield return [1]; + yield return [(uint) 1]; + yield return [(ulong) 1]; + yield return [(ushort) 1]; + yield return [(decimal) 1.1]; + yield return [(float) 1.1]; + yield return [new Guid("ebced679-45d3-4653-8791-3d969c4a986c")]; + yield return [new DateTime(2000, 1, 1, 1, 1, 1, DateTimeKind.Utc).ToUniversalTime()]; + yield return [new DateTimeOffset(2000, 1, 1, 1, 1, 1, 1, TimeSpan.FromHours(1)).ToUniversalTime()]; #if NET6_0_OR_GREATER - yield return new object[] {(Half) 10}; - yield return new object[] {new Date(2000, 1, 1)}; - yield return new object[] {new Time(1, 1)}; + yield return [(Half) 10]; + yield return [new Date(2000, 1, 1)]; + yield return [new Time(1, 1)]; #endif } } \ No newline at end of file