Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Sep 26, 2023
1 parent 308458d commit bea501a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 85 deletions.
13 changes: 2 additions & 11 deletions docs/parameterised.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,17 +276,8 @@ When using a [TestFixtureSource](https://docs.nunit.org/articles/nunit/writing-t
<a id='snippet-TestFixtureSourceUsage.cs'></a>
```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(
Expand All @@ -311,7 +302,7 @@ public class TestFixtureSourceUsage
};
}
```
<sup><a href='/src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs#L1-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestFixtureSourceUsage.cs' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs#L1-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-TestFixtureSourceUsage.cs' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

Produces `TestFixtureSourceUsage(Value1,1).Test.verified.txt` and `TestFixtureSourceUsage(Value2,2).Test.verified.txt`.
Expand Down
11 changes: 1 addition & 10 deletions src/Verify.NUnit.Tests/TestFixtureSourceUsage.cs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
11 changes: 1 addition & 10 deletions src/Verify.NUnit.Tests/TestFixtureSourceUsageExtraParameters.cs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
11 changes: 1 addition & 10 deletions src/Verify.NUnit.Tests/TestFixtureSourceUsageWithNamespace.cs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
94 changes: 50 additions & 44 deletions src/Verify.Tests/SimpleTypeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public Task Run(object arg)

[Fact]
public Task StringNullWrappedInTask() =>
Verify(Task.FromResult((string)null!));
Verify(Task.FromResult((string) null!));

[Fact]
public Task StringEmpty() =>
Verify(string.Empty);

[Fact]
public Task StringNull() =>
Verify((string?)null);
Verify((string?) null);

[Fact]
public Task Null() =>
Verify((object?)null);
Verify((object?) null);

[Fact]
public Task NullWrappedInTask() =>
Expand All @@ -53,52 +53,58 @@ public Task Run(object arg)

public static IEnumerable<object[]> GetData()
{
yield return new object[] {new KeyValuePair<string,int>("theKey",10)};
yield return [new KeyValuePair<string, int>("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
}
}

0 comments on commit bea501a

Please sign in to comment.