v2
v3
Hidden
xUnit2001
"Do not use invalid equality check"
Cause
Assert.Equals or Assert.ReferenceEquals is used.
Reason for rule
Assert.Equals does not assert that two objects are equal; it exists only to hide the static Equals method inherited from object. It's a similar story for Assert.ReferenceEquals.
How to fix violations
To fix a violation of this rule, use Assert.Equal instead of Equals and Assert.Same instead of ReferenceEquals.
Examples
Violates
using Xunit;
public class xUnit2001
{
[Fact]
public void TestMethod()
{
var result = 21 * 2;
Assert.Equals(42, result);
}
}
Does not violate
using Xunit;
public class xUnit2001
{
[Fact]
public void TestMethod()
{
var result = 21 * 2;
Assert.Equal(42, result);
}
}