Constants and literals should be the expected argument
A violation of this rule occurs when the expected argument to Assert.Equal
, AssertNotEqual
, Assert.StrictEqual
, or Assert.NotStrictEqual
is not the expected value (such as a constant or literal).
The expected value in equality assertions should always be the expected argument. This will ensure that generated messages explaining the test failure will correctly match the situation.
To fix a violation of this rule, swap the arguments in the assertion, so that the expected value is the first.
using Xunit;
public class xUnit2000
{
[Fact]
public void TestMethod()
{
var result = 2 + 3;
Assert.Equal(result, 5);
}
}
using Xunit;
public class xUnit2000
{
[Fact]
public void TestMethod()
{
var result = 2 + 3;
Assert.Equal(5, result);
}
}