Shouldly
  • Overview
  • Contributing
  • Documentation
    • Getting Started
    • Configuration
    • Equality
      • ShouldBe
      • NotBe
      • Null
      • Bool
      • Flags
      • AssignableTo
      • OfType
      • OneOf
      • Greater/Less Than
      • InRange
      • MatchApproved
      • Enumerable
      • SameAs
      • String
      • ExampleClasses
    • String
      • ShouldBe
      • Match
      • Contain
      • Null and Empty
      • StartWith
      • EndWith
    • Enumerable
      • ShouldBe
      • All
      • Empty
      • OneOf
      • Contain
      • Unique
      • SubsetOf
      • Have
    • Dictionary
      • ContainKey
      • ContainKeyAndValue
    • Exceptions
      • Throw
      • NotThrow
    • SatisfyAllConditions
    • CompleteIn
    • DynamicShould
    • Upgrade 3 to 4
Powered by GitBook
On this page
  • ShouldBeNull
  • ShouldBeNullOrEmpty
  • ShouldBeEmpty
  • ShouldNotBeNull
  • ShouldNotBeNullOrEmpty
  • ShouldNotBeEmpty
Edit on GitHub
  1. Documentation
  2. String

Null and Empty

PreviousContainNextStartWith

Last updated 2 years ago

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

|

|

|

|

snippet source
snippet source
anchor
anchor
snippet source
anchor
snippet source
anchor
snippet source
anchor
snippet source
anchor