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
Edit on GitHub
  1. Documentation

SatisfyAllConditions

PreviousNotThrowNextCompleteIn

Last updated 2 years ago

var mrBurns = new Person { Name = null };
mrBurns.ShouldSatisfyAllConditions(
                    () => mrBurns.Name.ShouldNotBeNullOrEmpty(),
                    () => mrBurns.Name.ShouldBe("Mr.Burns"));

|

Exception

mrBurns
    should satisfy all the conditions specified, but does not.
The following errors were found ...
--------------- Error 1 ---------------
    mrBurns.Name (null)
        should not be null or empty

--------------- Error 2 ---------------
    mrBurns.Name
        should be
    "Mr.Burns"
        but was
    null

-----------------------------------------

Generic

var mrBurns = new Person { Name = null };
mrBurns.ShouldSatisfyAllConditions(
                    p => p.Name.ShouldNotBeNullOrEmpty(),
                    p => p.Name.ShouldBe("Mr.Burns"));

Exception

mrBurns
    should satisfy all the conditions specified, but does not.
The following errors were found ...
--------------- Error 1 ---------------
    p => p.Name (null)
        should not be null or empty

--------------- Error 2 ---------------
    p => p.Name
        should be
    "Mr.Burns"
        but was
    null

-----------------------------------------

|

snippet source
anchor
snippet source
anchor