Reputation: 21194
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?
Upvotes: 7
Views: 2894
Reputation: 21194
It looks like Fluent Assertions 2.x does not support this scenario. Using Fluent Assertions 3.x one can use:
collection.Should().OnlyContain(predicate)
Upvotes: 12