Skip to content

Commit a9cdd17

Browse files
committed
fix issues1351
1 parent 85ce69c commit a9cdd17

3 files changed

Lines changed: 70 additions & 15 deletions

File tree

Issue1351/Issue1351.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
<ItemGroup>
1212
<PackageReference Include="coverlet.collector" Version="6.0.0" />
1313
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
14-
<PackageReference Include="NUnit" Version="3.12.0" />
14+
<PackageReference Include="NUnit" Version="4.3.2" />
1515
<PackageReference Include="NUnit.Analyzers" Version="3.8.0" />
16-
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0-beta.1" />
17-
<PackageReference Include="Microsoft.Testing.Extensions.Telemetry" Version="2.0.1" />
18-
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.0.1" />
19-
<PackageReference Include="Microsoft.Testing.Extensions.VSTestBridge" Version="2.0.1" />
20-
<PackageReference Include="Microsoft.Testing.Platform" Version="2.0.1" />
21-
<PackageReference Include="Microsoft.Testing.Platform.MSBuild" Version="2.0.1" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="6.3.0-alpha.0.8" />
17+
<PackageReference Include="Microsoft.Testing.Extensions.Telemetry" Version="2.2.2" />
18+
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="2.2.2" />
19+
<PackageReference Include="Microsoft.Testing.Extensions.VSTestBridge" Version="2.2.2" />
20+
<PackageReference Include="Microsoft.Testing.Platform" Version="2.2.2" />
21+
<PackageReference Include="Microsoft.Testing.Platform.MSBuild" Version="2.2.2" />
2222
</ItemGroup>
2323
</Project>

Issue1351/UnitTest1.cs

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using NUnit.Framework;
1+
using NUnit.Framework;
22
using System.Collections;
33

44
namespace Issue1351
55
{
6-
//[TestFixture(1)]
7-
//[TestFixture(2)]
8-
//[TestFixtureSource(nameof(GetTestCases))]
6+
/// <summary>
7+
/// Parameterized fixture via TestFixtureSource with display names.
8+
/// TRX should show className="Issue1351.Tests(One)" / "Issue1351.Tests(Two)".
9+
/// </summary>
910
[TestFixtureSource(nameof(GetTestCasesWithNames))]
1011
public class Tests
1112
{
@@ -23,16 +24,62 @@ public void Test1()
2324
Assert.Pass();
2425
}
2526

27+
private static IEnumerable<TestFixtureData> GetTestCasesWithNames()
28+
{
29+
yield return new TestFixtureData(1).SetArgDisplayNames("One");
30+
yield return new TestFixtureData(2).SetArgDisplayNames("Two");
31+
}
32+
}
33+
34+
/// <summary>
35+
/// Parameterized fixture via TestFixtureSource without display names.
36+
/// TRX should show className="Issue1351.TestsWithGetCases(1)" / "(2)".
37+
/// </summary>
38+
[TestFixtureSource(nameof(GetTestCases))]
39+
public class TestsWithGetCases
40+
{
41+
private int _counter;
42+
43+
public TestsWithGetCases(int counter)
44+
{
45+
_counter = counter;
46+
}
47+
48+
[Test]
49+
public void Test1()
50+
{
51+
Console.WriteLine($"Test1:{_counter}");
52+
Assert.Pass();
53+
}
54+
2655
private static IEnumerable<TestFixtureData> GetTestCases()
2756
{
2857
yield return new TestFixtureData(1);
2958
yield return new TestFixtureData(2);
3059
}
60+
}
3161

32-
private static IEnumerable<TestFixtureData> GetTestCasesWithNames()
62+
/// <summary>
63+
/// Method-level parameters via [TestCase].
64+
/// TRX should show className="Issue1351.TestsWithMethodParams"
65+
/// and the TestMethodIdentifierProperty should carry parameterTypeFullNames=["System.Int32"].
66+
/// </summary>
67+
public class TestsWithMethodParams
68+
{
69+
[TestCase(1)]
70+
[TestCase(2)]
71+
public void TestWithIntParam(int value)
3372
{
34-
yield return new TestFixtureData(1).SetArgDisplayNames("One");
35-
yield return new TestFixtureData(2).SetArgDisplayNames("Two");
73+
Console.WriteLine($"TestWithIntParam:{value}");
74+
Assert.Pass();
75+
}
76+
77+
[TestCase(1, "hello")]
78+
[TestCase(2, "world")]
79+
public void TestWithTwoParams(int value, string label)
80+
{
81+
Console.WriteLine($"TestWithTwoParams:{value},{label}");
82+
Assert.Pass();
3683
}
3784
}
38-
}
85+
}

Issue1351/nuget.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<clear />
5+
<add key="local" value="C:\nuget" />
6+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
7+
</packageSources>
8+
</configuration>

0 commit comments

Comments
 (0)