Skip to content

Instantly share code, notes, and snippets.

View codingfab's full-sized avatar

Fabien Martinez codingfab

View GitHub Profile
@codingfab
codingfab / MyComplexMethodShould.cs
Last active December 28, 2019 14:23
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);
@codingfab
codingfab / MyComplexMethodShould.cs
Last active December 3, 2019 17:30
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);
@codingfab
codingfab / MyComplexMethodShould.cs
Last active December 1, 2019 19:51
Tests multiple data set with repeated TestCase attributes
[TestFixture]
public class MyComplexLogicShould
{
[Test]
[TestCase(10, 22, ExpectedResult = 32)]
[TestCase(20, 44, ExpectedResult = 64)]
[TestCase(15, 17, ExpectedResult = 32)]
public int ReturnExpectedResult(int a, int b)
{
var sut = new MyClass();
@codingfab
codingfab / MyComplexMethodShould.cs
Last active December 1, 2019 19:44
ExpectedResult usage
[TestFixture]
public class MyComplexLogicShould
{
[Test]
[TestCase(10, 22, ExpectedResult = 32)]
public int ReturnExpectedResult(int a, int b)
{
var sut = new MyClass();
return sut.MyComplexLogic(a,b);
@codingfab
codingfab / MyComplexMethodShould.cs
Last active December 3, 2019 17:10
Starting point
[TestFixture]
public class MyComplexLogicShould
{
[Test]
public void ReturnExpectedResult()
{
// Arrange
var a = 10;
var b = 22;
var expected = 32;
@codingfab
codingfab / MyComplexMethodShould.cs
Last active December 3, 2019 17:17
Simple TestCase attribute usage
[TestFixture]
public class MyComplexLogicShould
{
[Test]
[TestCase(10,22,32)]
public void ReturnExpectedResult(int a, int b, int expected)
{
// Arrange
var sut = new MyClass();