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
  • ShouldContain
  • ShouldContainWithoutWhitespace
  • ShouldNotContain
Edit on GitHub
  1. Documentation
  2. String

Contain

PreviousMatchNextNull and Empty

Last updated 2 years ago

ShouldContain

var target = "Homer";
target.ShouldContain("Bart");

|

Exception

target
    should contain (case insensitive comparison)
"Bart"
    but was actually
"Homer"

ShouldContainWithoutWhitespace

var target = "Homer Simpson";
target.ShouldContainWithoutWhitespace(" Bart Simpson ");

|

Exception

target
    should contain without whitespace
" Bart Simpson "
    but was actually
"Homer Simpson"

ShouldNotContain

var target = "Homer";
target.ShouldNotContain("Home");

Exception

target
    should not contain (case insensitive comparison)
"Home"
    but was actually
"Homer"

|

snippet source
snippet source
anchor
anchor
snippet source
anchor