Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

Created Issue: BeNull and NotBeNull have the same condition for comparable types [12456]

$
0
0
I have a reference type implementing IComparable<T> that I assert to be null:

value.Should().BeNull();

The test unexpectedly fails when the value is indeed null (verified in the debugger). When I change the assertion to explicitly check for null, the test passes:

value.Should().Be(null);

I determined that the assertion is of type ComparableTypeAssertions<> and found the implementation of BeNull here:

http://fluentassertions.codeplex.com/SourceControl/changeset/view/9808ede8793e#Main%2fFluentAssertions.Net35%2fNumeric%2fComparableTypeAssertions.cs

I am not versed in the Execute.Verification syntax, but I did notice that both the BeNull and NotBeNull methods have the same condition:

.ForCondition(!ReferenceEquals(Subject, null))

As those two conditions are the inverse of each other, this seems incorrect and a possible culprit for the expected outcome of BeNull.

Viewing all articles
Browse latest Browse all 1402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>