1

Closed

BeNull and NotBeNull have the same condition for comparable types

description

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.
Closed Mar 4 at 11:24 AM by dennisdoomen
Was already fixed in 2.0.0

comments