Create a gist now

Instantly share code, notes, and snippets.

@vkhorikov /1.cs
Last active Jan 30, 2018

What would you like to do?
Leaking domain knowledge to tests
public static class Calculator
{
public static int Add(int value1, int value2)
{
return value1 + value2;
}
}
public class CalculatorTests
{
[Fact]
public void Add_two_numbers()
{
int value1 = 1;
int value2 = 3;
int expected = value1 + value2;
int actual = Calculator.Add(value1, value2);
Assert.Equal(expected, actual);
}
}
public class CalculatorTests
{
[Theory]
[InlineData(1, 3)]
[InlineData(11, 33)]
[InlineData(100, 500)]
public void Add_two_numbers(int value1, int value2)
{
int expected = value1 + value2;
int actual = Calculator.Add(value1, value2);
Assert.Equal(expected, actual);
}
}
int expected = value1 + value2;
public static int Add(int value1, int value2)
{
return value1 + value2;
}
public class CalculatorTests
{
[Fact]
public void Add_two_numbers()
{
Assert.True(true);
}
}
public class CalculatorTests
{
[Theory]
[InlineData(1, 3, 4)]
[InlineData(11, 33, 44)]
[InlineData(100, 500, 600)]
public void Add_two_numbers(int value1, int value2, int expected)
{
int actual = Calculator.Add(value1, value2);
Assert.Equal(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment