Skip to content

Commit

Permalink
Add TestsCaseSource to test TestCaseSourceAttribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Sep 11, 2024
1 parent 79d79be commit b961243
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Support tests with `TestCaseSource`.
### Application
- Update `ricaun.NUnit` to `1.4.0`.
### Tests
- Add `TestsCaseSource` to test `TestCaseSourceAttribute`.

## [1.4.1] / 2024-09-06
### TestAdapter
Expand Down
59 changes: 59 additions & 0 deletions ricaun.RevitTest.Tests/TestsCaseSource.cs
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 }
};
}
}
}

0 comments on commit b961243

Please sign in to comment.