How to check that each object of a collection conforms to a given predicate? E.g.: check for each item (from a given collection) that it matches a given predicate (MyPredicate
). Code should probably look something like this:
collection.Should().AllMatch(item => MyPredicate(item));
Is something like that available or do I have to write it myself?
It looks like Fluent Assertions 2.x does not support this scenario. Using Fluent Assertions 3.x one can use:
collection.Should().OnlyContain(predicate)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With