Assertions on each member of a sequence

Apr 21, 2010 at 11:23 AM

Hi,

Thanks for writing and publishing this. I'm just in the process of moving from my home-grown fluent assertions framework to #TestsEx, however I have a useful helper method which doesn't seem to be here.

I would like to able to make some assertion on every member of a sequence (IEnumerable<T>) - it might look like so in your framework:

sequence.Each().Should().Not.Be.Null();

Is this technically possible?

Matt

Coordinator
Apr 21, 2010 at 10:29 PM

sequence.All(x=> x.Satisfy(a=> a != null));

Apr 21, 2010 at 11:40 PM

Ahah, I hadn't noticed that Satisfy returns bool. Thanks!