Skip to content

Instantly share code, notes, and snippets.

@codingfab
Last active December 28, 2019 14:23
Show Gist options
  • Save codingfab/f16c58dcc518607deddbafe9576418ea to your computer and use it in GitHub Desktop.
Save codingfab/f16c58dcc518607deddbafe9576418ea to your computer and use it in GitHub Desktop.
Usage of TestCaseSource attribute with class property
[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