Looking for an item in a collection having all properties but

May 24, 2012 at 7:53 AM
Edited May 24, 2012 at 8:20 AM

Hi,

I need to assert in case a collection does not contain a specific item. The problem is that due to precision issues in DateTime property (ms & tick count are truncated while reading from DB), I'd like to exclude these properties tests (and maybe compare them seperatlly). 

So basically I'm looking for an example for the following use case:

actualCollection.Should().Contain(expectedItem).Having.AllPropertiesBut( obj => obj.Date)

or,

another optional solution whould be something like:

actualCollection.Should().Contain( (IEquatable<MyType>)expectedItem ); //for using IEquatable<>.Equals()

 

Thanks,

Udi