Last active
December 28, 2019 14:23
-
-
Save codingfab/f16c58dcc518607deddbafe9576418ea to your computer and use it in GitHub Desktop.
Usage of TestCaseSource attribute with class property
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
[TestFixture] | |
public class MyComplexLogicShould | |
{ | |
[Test] | |
[TestCaseSource(typeof(MyTestCases),"TestData")] | |
public int ReturnExpectedResult(int a, int b) | |
{ | |
var sut = new MyClass(); | |
return sut.MyComplexLogic(a,b); | |
} | |
} | |
public class MyTestCases | |
{ | |
public static IEnumerable<TestCaseData> TestData | |
{ | |
get | |
{ | |
yield return new TestCaseData(10,22).Returns(32); | |
yield return new TestCaseData(20,44).Returns(64); | |
yield return new TestCaseData(15,17).Returns(32); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment