Fluentassertions: Support for collection.ShouldContainEquivalentOf

Created on 4 Mar 2016  路  4Comments  路  Source: fluentassertions/fluentassertions

As far as I can tell, Should().Contain() uses Equals() to compare objects. It would be nice to be able to combine Should().Contain() and Should().BeEquivalent() and leverage structural equality instead.

We already have ShouldAllBeEquivalentTo(), this could be called ShouldSomeBeEquivalentTo() or ShouldContainEquivalentOf().

Thanks for this awesome library !

enhancement help wanted

Most helpful comment

Issue #584 was a duplicate of this, and was closed in #950. Please close this one too.

All 4 comments

Maybe by adding a Should().ContainEquivalentOf which internally leverages the structural equivalency API.

Hi guys,

Is there a workaround to achieve the same result with the current version?

Thank you!

You can build your own extension that passes each object in the collection to a call to ShouldBeEquivalenTo to compare each object with the one you like to find. At least one of those objects in the collection must match.

Issue #584 was a duplicate of this, and was closed in #950. Please close this one too.

Was this page helpful?
0 / 5 - 0 ratings