-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
TestsCaseSource
to test TestCaseSourceAttribute
.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
|
||
namespace ricaun.RevitTest.Tests | ||
{ | ||
public class TestsCaseSource | ||
{ | ||
public static int[] CasesSource = new[] { 1, 2, 3 }; | ||
[TestCaseSource(nameof(CasesSource))] | ||
public void CasesSourceTest(int i) | ||
{ | ||
Assert.True(i > 0); | ||
} | ||
|
||
|
||
static IEnumerable<int> CasesSourceMethod() | ||
{ | ||
yield return 1; | ||
yield return 2; | ||
yield return 3; | ||
} | ||
[TestCaseSource(nameof(CasesSourceMethod))] | ||
public void CasesSourceMethodTest(int i) | ||
{ | ||
Assert.True(i > 0); | ||
} | ||
|
||
static IEnumerable<int> CasesSourceMethodWithParameters(int start, int count) | ||
{ | ||
for (int i = 0; i < count; i++) | ||
{ | ||
yield return start + i; | ||
} | ||
} | ||
|
||
[TestCaseSource(nameof(CasesSourceMethodWithParameters), new object[] { 1, 4 })] | ||
public void CasesSourceMethodWithParametersTest(int i) | ||
{ | ||
Assert.True(i > 0); | ||
} | ||
|
||
[TestCaseSource(typeof(AnotherClass), nameof(AnotherClass.CasesSource))] | ||
public void CasesSourceAnotherClassTest(int i, int j, int k) | ||
{ | ||
Assert.True(i > 0); | ||
Assert.True(j > 0); | ||
Assert.True(k > 0); | ||
} | ||
public class AnotherClass | ||
{ | ||
public static object[] CasesSource = | ||
{ | ||
new object[] { 1, 2, 3 }, | ||
new object[] { 2, 3, 4 }, | ||
new object[] { 3, 4, 5 } | ||
}; | ||
} | ||
} | ||
} |