For the complete documentation index, see llms.txt. This page is also available as Markdown.

SatisfyAllConditions

Asserts that every one of the supplied conditions holds, reporting all the failures at once rather than stopping at the first.

Which form to use:

  • All the assertions hang off a common subject → use the value.ShouldSatisfy([...]) extension method. The value under test is passed to each condition, and it appears as the subject in the failure message.

  • A group of otherwise unrelated assertions → use the static Should.Satisfy([...]) method. There is no single subject to pass, so each condition is a self-contained assertion.

ShouldSatisfyAllConditions is the original name for this assertion. It still works but is now obsolete: it cannot capture the asserted expression via CallerArgumentExpression and falls back to stack-trace parsing, which is not trim- or AOT-safe. Prefer ShouldSatisfy / Should.Satisfy.

A common subject — ShouldSatisfy

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

snippet source | anchor

Exception

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

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

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

Unrelated conditions — Should.Satisfy

snippet source | anchor

Exception

Last updated