Last active
August 29, 2015 14:02
-
-
Save adamralph/ac0deea6448da5a93359 to your computer and use it in GitHub Desktop.
FluentAssertions enumerable assertion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IEnumerable<Foo> foos; | |
foos.Should().All(foo => foo.Bar.Should().Be("baz")); | |
// if an item does not satisfy the inner assertion, I'd like to be told which one. | |
// perhaps I could be told the index, and maybe a string representation of the item |
I've done that for simple cases, but in other cases, I want to do more than just an equality comparison. I'd like to use some of the much richer assertions that FluentAssertions provides.
So you essentially want to have some kind of nested assertions? If so, I think we can do that using the AssertionScope
and the CollectingAssertionStrategy
. Can you create a request on the FA for that?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about this?
foos.Should().OnlyContain(foo => foo.Bar == "baz");