Quantcast
Channel: Fluent Assertions
Viewing all articles
Browse latest Browse all 1402

New Post: Error when validating a list

$
0
0
I knew it was something simple. Thanks!!

Sent from my iPhone

On May 15, 2012, at 2:58 AM, dennisdoomen <notifications@codeplex.com> wrote:

From: dennisdoomen

That's because collection.Should().BeEquivalentTo() relies on the Equals() implementation of those items. And if you don't explicitly implement Equals(), it will rely on the default .NET Framework provided implementation that uses a reference comparision. So your observed behavior is perfectly ok.

So either implement Equals() and GetHashCode(), or use the object.ShouldHave().AllProperties.EqualTo(). You do need 1.7.1 though, because that one introduces support for comparing collections of objects based on their proeprties.


Viewing all articles
Browse latest Browse all 1402

Trending Articles