Skip to content

Commit

Permalink
Add tests with TestCaseData class.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Sep 12, 2024
1 parent b961243 commit 6669652
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 11 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [1.4.2] / 2024-09-11
### Features
- Support tests with `TestCaseSource`.
- Support tests with `TestCaseSource`. (Fix: #55)
### Application
- Update `ricaun.NUnit` to `1.4.0`.
- Update `ricaun.NUnit` to `1.4.0-beta`.
### Tests
- Add `TestsCaseSource` to test `TestCaseSourceAttribute`.
- Add tests with `TestCaseData` class.

## [1.4.1] / 2024-09-06
### TestAdapter
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>1.4.2-alpha</Version>
<Version>1.4.2-beta</Version>
</PropertyGroup>
</Project>
Binary file not shown.
Binary file not shown.
Binary file not shown.
31 changes: 23 additions & 8 deletions ricaun.RevitTest.Tests/TestsCaseSource.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;

namespace ricaun.RevitTest.Tests
Expand All @@ -12,7 +13,6 @@ public void CasesSourceTest(int i)
Assert.True(i > 0);
}


static IEnumerable<int> CasesSourceMethod()
{
yield return 1;
Expand All @@ -32,28 +32,43 @@ static IEnumerable<int> CasesSourceMethodWithParameters(int start, int count)
yield return start + i;
}
}

[TestCaseSource(nameof(CasesSourceMethodWithParameters), new object[] { 1, 4 })]
public void CasesSourceMethodWithParametersTest(int i)
{
Assert.True(i > 0);
}

public class AnotherClass
{
public static object[] CasesSource =
{
new object[] { 1, 2, 3 },
new object[] { 2, 3, 4 },
new object[] { 3, 4, 5 }
};
}
[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 IEnumerable TestCaseDatas
{
public static object[] CasesSource =
get
{
new object[] { 1, 2, 3 },
new object[] { 2, 3, 4 },
new object[] { 3, 4, 5 }
};
yield return new TestCaseData(0).Returns(false);
yield return new TestCaseData(1).Returns(true);
yield return new TestCaseData(2).Returns(true);
yield return new TestCaseData(3).Returns(true);
}
}
[TestCaseSource(nameof(TestCaseDatas))]
public bool CasesSourceTestCaseDataTest(int i)
{
return i > 0;
}
}
}

0 comments on commit 6669652

Please sign in to comment.