Skip to content

Commit

Permalink
Update TestFixtureAttributeExamples.cs To give an example of using pa…
Browse files Browse the repository at this point in the history
…rams in a constructor
  • Loading branch information
Shiney authored Oct 15, 2023
1 parent 60f4b56 commit eb5fa74
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class TestFixtureAttributeExamples
[TestFixture("hello", "hello", "goodbye")]
[TestFixture("zip", "zip")]
[TestFixture(42, 42, 99)]
[TestFixture('a', 'a', 'b')]
[TestFixture('A', 'A')]
public class ParameterizedTestFixture
{
private readonly string _eq1;
Expand All @@ -37,6 +39,17 @@ public ParameterizedTestFixture(int eq1, int eq2, int neq)
_neq = neq.ToString();
}

// Can use params arguments (but not yet optional arguments)
public ParameterizedTestFixture(params char[] eqArguments)

Check warning on line 43 in docs/snippets/Snippets.NUnit/Attributes/TestFixtureAttributeExamples.cs

View workflow job for this annotation

GitHub Actions / Build/Test Snippets

Non-nullable field '_neq' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.

Check warning on line 43 in docs/snippets/Snippets.NUnit/Attributes/TestFixtureAttributeExamples.cs

View workflow job for this annotation

GitHub Actions / Build/Test Snippets

Non-nullable field '_neq' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
{
_eq1 = eqArguments[0].ToString();
_eq2 = eqArguments[1].ToString();
if (eqArgument.Length > 2)

Check failure on line 47 in docs/snippets/Snippets.NUnit/Attributes/TestFixtureAttributeExamples.cs

View workflow job for this annotation

GitHub Actions / Build/Test Snippets

The name 'eqArgument' does not exist in the current context

Check failure on line 47 in docs/snippets/Snippets.NUnit/Attributes/TestFixtureAttributeExamples.cs

View workflow job for this annotation

GitHub Actions / Build/Test Snippets

The name 'eqArgument' does not exist in the current context
{
_neq = eqArguments[2].ToString();
}
}

[Test]
public void TestEquality()
{
Expand Down Expand Up @@ -162,4 +175,4 @@ public void TestMyArgTypes(T1 t1, T2 t2)
}
}
#endregion
}
}

0 comments on commit eb5fa74

Please sign in to comment.