diff --git a/CHANGELOG.md b/CHANGELOG.md index 2216ac7..90a30ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ricaun.RevitTest.Tests/TestsCaseSource.cs b/ricaun.RevitTest.Tests/TestsCaseSource.cs new file mode 100644 index 0000000..7864749 --- /dev/null +++ b/ricaun.RevitTest.Tests/TestsCaseSource.cs @@ -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 CasesSourceMethod() + { + yield return 1; + yield return 2; + yield return 3; + } + [TestCaseSource(nameof(CasesSourceMethod))] + public void CasesSourceMethodTest(int i) + { + Assert.True(i > 0); + } + + static IEnumerable 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 } + }; + } + } +}