Suppose for the sake of this bug report that we have the following type:
public interface IExample {
double Amount { get; }
}
Then if we write the following incorrect test:
public void TestMethod() {
IExample? actual = null;
actual?.Amount.Should().BeApproximately(3.14, 0.01); // no FAA0001 here?!
}
then we get no message from FluentAssertions.Analyzers about the wrong code.
For other assertions, this works fine. For example:
actual?.Amount.Should().BeGreaterThan(3.1); // good, we get 'FAA0001: Use .Should() instead of ?.Should()'
or:
actual?.Amount.Should().BePositive(); // good, we get 'FAA0001: Use .Should() instead of ?.Should()'
or:
actual?.Amount.Should().BeInRange(3.1, 3.2); // good, we get 'FAA0001: Use .Should() instead of ?.Should()'
We need the FAA0001 with .BeApproximately(3.14, 0.01) as well. Without it, the author may think his tests proves actual is an instance where Amount equals 3.14 within a tolerance of 0.01 when in fact actual is a null reference (and no Amount exists).
Suppose for the sake of this bug report that we have the following type:
Then if we write the following incorrect test:
then we get no message from
FluentAssertions.Analyzersabout the wrong code.For other assertions, this works fine. For example:
or:
or:
We need the FAA0001 with
.BeApproximately(3.14, 0.01)as well. Without it, the author may think his tests provesactualis an instance whereAmountequals3.14within a tolerance of0.01when in factactualis a null reference (and noAmountexists).