FluentAssertions: matches each collection object

How to check that each collection object corresponds to a given predicate? For example: check for each element (from this collection) that it matches the given predicate ( MyPredicate). The code should look something like this:

collection.Should().AllMatch(item => MyPredicate(item));

Is something like this accessible or do I need to write it myself?

+4
source share
1 answer

Fluent Assertions 2.x does not seem to support this scenario. Using Fluent Assertions 3.x you can use:

collection.Should().OnlyContain(predicate)
+7
source

Source: https://habr.com/ru/post/1538589/


All Articles