[Test] public void TestAddition() { int result = Calculator.Add(2, 3); Assert.AreEqual(5, result); }
[TestCase(2, 3, 5)] [TestCase(0, 0, 0)] [TestCase(-2, 3, 1)] public void TestAddition(int a, int b, int expected) { int result = Calculator.Add(a, b); Assert.AreEqual(expected, result); }
[Test] [TestCaseSource(typeof(TestData), "GetTestData")] public void TestAddition(int a, int b, int expected) { int result = Calculator.Add(a, b); Assert.AreEqual(expected, result); }Package/Library: NUnit, CsvHelper In this example, the test data is stored in a CSV file and is read using the CsvHelper library. The `TestCaseSource` attribute specifies the source of the test data. The `TestData` class and `GetTestData` method are responsible for reading the CSV file and returning the test data as parameters.