1- using NUnit . Framework ;
1+ using NUnit . Framework ;
22using System . Collections ;
33
44namespace 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+ }
0 commit comments