Do not use boolean check to check for string equality
A violation of this rule occurs when Assert.True
or Assert.False
are used with string.Equals
to check if two strings are equal.
Assert.Equal
or Assert.Equal
should be used because they give more detailed information upon failure.
Replace Assert.True
with Assert.Equal
and/or Assert.False
with Assert.NotEqual
.
using Xunit;
public class xUnit2010
{
[Fact]
public void TestMethod()
{
var result = "foo bar baz";
Assert.True(string.Equals("foo bar baz", result));
}
}
using Xunit;
public class xUnit2010
{
[Fact]
public void TestMethod()
{
var result = "foo bar baz";
Assert.Equal("foo bar baz", result);
}
}