nunit Fluent Assertions Advanced Constraint Usage


Large fluent assertions do become harder to read, but when combined with classes that have good implementations of ToString(), they can generate very useful error messages.

public void AdvancedContraintsGiveUsefulErrorMessages() {
    Assert.That(actualCollection, Has

On failure, this assertion generates messages like this:

Expected: property Count equal to 4 and exactly one item property Age greater
than 60 and some item property Address null and not property Age less than or
equal to 17
But was:  < <Steve Taylor (23) lives in Newcastle
>, <Michelle Yung (65) lives in San Francisco
>, <Ranjit Saraman (49) lives in Milano
>, <LaChelle Oppenheimer (16) lives in 
> >