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

Closed Issue: TypeAssertions throws NullReferenceException when checking Should().Be(null) [12460]

$
0
0
FluentAssertions 1.7.1, net35 version.

Type type = GetNullType();
type.Should().Be(null);

throws NullReferenceException if type is null:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
TypeAssertions.GetFailureMessageIfTypesAreDifferent(Type actual, Type expected)
TypeAssertions.Be(Type expected, String reason, Object[] reasonArgs)
TypeAssertions.Be(Type expected)
...

A valid workaround:

Object type = GetNullType();
type.Should().Be(null); // or type.Should().BeNull();

Asides from the unexpected exception, I think TypeAssertions should provide a BeNull method also.
Comments: Was already fixed in 2.0.0

Viewing all articles
Browse latest Browse all 1402

Trending Articles



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