You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No FAA0001 when ?. is followed by Should().BeApproximately #405
Suppose for the sake of this bug report that we have the following type:
publicinterfaceIExample{doubleAmount{get;}}
Then if we write the following incorrect test:
publicvoidTestMethod(){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).
Activity