Last active
February 6, 2025 23:34
-
-
Save digicjm/8d0b79f22b3c4ad46cf50e7321947a74 to your computer and use it in GitHub Desktop.
This file contains 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
using Xunit; | |
public class CalculatorTests | |
{ | |
private readonly Calculator _calculator; | |
// Constructor-based setup (no [TestInitialize]) | |
public CalculatorTests() | |
{ | |
_calculator = new Calculator(); | |
} | |
[Fact] // Equivalent to [TestMethod] in MSTest | |
public void Add_ShouldReturnCorrectSum_WhenNumbersAreIntegers() | |
{ | |
var result = _calculator.Add(2, 3); | |
Assert.Equal(5, result); // xUnit assertion | |
} | |
[Theory] // Supports data-driven tests | |
[InlineData(2, 3, 5)] | |
[InlineData(-1, -1, -2)] | |
public void Add_ShouldReturnExpectedResults_WhenNumbersAreIntegers(int a, int b, int expected) | |
{ | |
var result = _calculator.Add(a, b); | |
Assert.Equal(expected, result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment