@@ -11,20 +11,7 @@ its data using one of the forms of **TestFixtureSourceAttribute**:
1111
1212### Form 1 - [ TestFixtureSource(string sourceName)]
1313
14- ``` csharp
15- [TestFixtureSource (nameof (FixtureArgs ))]
16- public class MyTestClass
17- {
18- public MyTestClass (string word , int num ) { .. . }
19-
20- /* ... */
21-
22- static object [] FixtureArgs = {
23- new object [] { " Question" , 1 },
24- new object [] { " Answer" , 42 }
25- };
26- }
27- ```
14+ [ !code-csharp[ BasicTestFixtureSource] ( ~/snippets/Snippets.NUnit/Attributes/TestFixtureSourceAttributeExamples.cs#StaticPropertyInOwnClass )]
2815
2916The single attribute argument in this form is a string representing the name of the source used to provide arguments for
3017constructing the ` TestFixture ` . It has the following characteristics:
@@ -40,23 +27,7 @@ constructing the `TestFixture`. It has the following characteristics:
4027
4128### Form 2 - [ TestFixtureSource(Type sourceType, string sourceName)]
4229
43- ``` csharp
44- [TestFixtureSource (typeof (AnotherClass ), nameof (AnotherClass .FixtureArgs )]
45- public class MyTestClass
46- {
47- public MyTestClass (string word , int num ) { .. . }
48-
49- .. .
50- }
51-
52- class AnotherClass
53- {
54- static object [] FixtureArgs = {
55- new object [] { " Question" , 1 },
56- new object [] { " Answer" , 42 }
57- };
58- }
59- ```
30+ [ !code-csharp[ StaticPropertyInAnotherClass] ( ~/snippets/Snippets.NUnit/Attributes/TestFixtureSourceAttributeExamples.cs#StaticPropertyInAnotherClass )]
6031
6132The first argument of the attribute in this form is a Type representing the class that will provide the test fixture
6233data.
@@ -75,42 +46,26 @@ characteristics:
7546
7647### Form 3 - [ TestFixtureSource(Type sourceType)]
7748
78- ```csharp
79- [TestFixtureSource (typeof (FixtureArgs ))]
80- public class MyTestClass
81- {
82- public MyTestClass (string word , int num ) { /* ... */ }
83-
84- /* ... */
85- }
86-
87- class FixtureArgs : IEnumerable
88- {
89- public IEnumerator GetEnumerator ()
90- {
91- yield return new object [] { " Question" , 1 };
92- yield return new object [] { " Answer" , 42 };
93- }
94- }
95- ```
96-
97- The Type argument in this form represents the class that provides test cases . It must have a default constructor and
49+ [ !code-csharp[ SourceFromEnumerable] ( ~/snippets/Snippets.NUnit/Attributes/TestFixtureSourceAttributeExamples.cs#SourceFromEnumerable )]
50+
51+ The Type argument in this form represents the class that provides test fixtures. It must have a default constructor and
9852implement ` IEnumerable ` .
9953
10054The individual items returned by the enumerator must either be object arrays or derive from the ` TestFixtureParameters `
10155class. Arguments must be consistent with the fixture constructor.
10256
10357## Named Parameters
10458
105- `TestCaseSourceAttribute ` supports one named parameter :
59+ ` TestFixtureSourceAttribute ` supports two named parameters :
10660
107- * ** Category ** is used to assign one or more categories to every test case returned from this source .
61+ * ** Category** is used to assign one or more categories to every test fixture returned from this source.
62+ * ** TypeArgs** can be used to explicitly specify the ` Type ` s to be used when constructing a generic test fixture. (_ NUnit 4.5+_ )
10863
109- ## Test Case Construction
64+ ## Test Fixture Construction
11065
111- In constructing tests , NUnit uses each item returned by the enumerator as follows :
66+ In constructing fixtures , NUnit uses each item returned by the enumerator as follows:
11267
113- * If it is an object deriving from `TestFixtureParameters `, its properties are used to provide the test case . NUnit
68+ * If it is an object deriving from ` TestFixtureParameters ` , its properties are used to provide the test fixture's data . NUnit
11469 provides the [ TestFixtureData] ( xref:testfixturedata ) class for this purpose.
11570* If it is an ` object[] ` , its members are used to provide the arguments for the method. This is the approach taken in
11671 the examples above.
0 commit comments