[TestCase(0, 0, 0)]
[TestCase(34, 25, 59)]
[TestCase(-1250, 10000, 8750)]
public void AddNumbersTest(int a, int b, int expected)
{
// Act
int result = a + b;
// Assert
Assert.That(result, Is.EqualTo(expected));
}
[TestFixture]
public class Tests {
[Test]
public void Test1() {
Assert.That(true, Is.EqualTo(true));
}
}
A test fixture marks a class as containing tests.
This attribute used t identify a method that is called once to perform setup before any child tests are run. For the new versions we are using OneTimeSetUp as the TestFixtureSetUp is obsolete.
OneTimeSetUp
[OneTimeSetUp]
public void SetUp()
{
}
This attribute is used to identify a method that is called immediately after each tests, it will be called even if there is any error, this is the place we can dispose our objects.
[TearDown]
public void CleanAfterEveryTest()
{
}
The ValuesAttribute is used to specify a set of values for an individual parameter of a test method with parameters.
[Test]
public void Sum_Works_Correctly(
[Values(1, 2, 3)] int x,
[Values(4, 5)] int y)
{
// Arrange
var calculator = new Calculator(...