-
-
Save vkhorikov/9aec89234c07b5f1a949f34c12c3c219 to your computer and use it in GitHub Desktop.
Leaking domain knowledge to tests
This file contains hidden or 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
public static class Calculator | |
{ | |
public static int Add(int value1, int value2) | |
{ | |
return value1 + value2; | |
} | |
} |
This file contains hidden or 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
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); | |
} | |
} |
This file contains hidden or 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
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); | |
} | |
} |
This file contains hidden or 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
int expected = value1 + value2; |
This file contains hidden or 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
public static int Add(int value1, int value2) | |
{ | |
return value1 + value2; | |
} |
This file contains hidden or 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
public class CalculatorTests | |
{ | |
[Fact] | |
public void Add_two_numbers() | |
{ | |
Assert.True(true); | |
} | |
} |
This file contains hidden or 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
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