Skip to content

Instantly share code, notes, and snippets.

@codingfab
Last active December 3, 2019 17:30
Show Gist options
  • Save codingfab/9a3152d6300c1f79cb0f2677763e7985 to your computer and use it in GitHub Desktop.
Save codingfab/9a3152d6300c1f79cb0f2677763e7985 to your computer and use it in GitHub Desktop.
Usage of TestCaseSource attribute with method name
[TestFixture]
public class MyComplexLogicShould
{
[Test]
[TestCaseSource(nameof(GetTestCases))]
public int ReturnExpectedResult(int a, int b)
{
var sut = new MyClass();
return sut.MyComplexLogic(a,b);
}
public static IEnumerable<TestCaseData> GetTestCases()
{
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