Shouldly
Search
K
Comment on page

Null and Empty

ShouldBeNull

var target = "Homer";
target.ShouldBeNull();
Exception
target
should be null but was
"Homer"

ShouldBeNullOrEmpty

var target = "Homer";
target.ShouldBeNullOrEmpty();
Exception
target ("Homer")
should be null or empty

ShouldBeEmpty

var target = "Homer";
target.ShouldBeEmpty();
Exception
target
should be empty but was
"Homer"

ShouldNotBeNull

string? target = null;
target.ShouldNotBeNull();
Exception
target
should not be null but was

ShouldNotBeNullOrEmpty

var target = "";
target.ShouldNotBeNullOrEmpty();
Exception
target ("")
should not be null or empty

ShouldNotBeEmpty

var target = "";
target.ShouldNotBeNullOrEmpty();
Exception
target
should not be empty but was
Last modified 7mo ago