0

I have two objects (instances of the same class) with a bunch of properties, some of them lists of other objects.

class A  {
    public int a { get; set; }
    public string b { get; set; }
    public IList<C> cs { get; set; }
}

I want to compare these using the FluentAssertions library, and make sure they have the same properties, so I add

first.ShouldHave().AllProperties().EqualTo(second);

but then I get an error that

Expected property cs to have value <C, C, C> but found <C, C, C>

In other words, when comparing properties that are lists, it does a reference-equals, which obviously fails in this case.

How do I tell FluentAssertions to assert that the properties of the elements in the lists are equal, rather than the lists themselves?

Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402

1 Answers1

0

This is supported as of version 1.7.0. Read the release notes here. http://www.dennisdoomen.net/2012/01/fluent-assertions-170-has-been-released.html

Dennis Doomen
  • 8,368
  • 1
  • 32
  • 44
  • Unfortunately, I'm not at liberty to upgrade at the moment - that will have to go through the chain of decisions in our development team first. But the fact that I would have to upgrade to get the functionality answers my question anyway =) Thanks! – Tomas Aschan Jan 24 '12 at 18:53
  • Well, version 1.7.0 is backwards compatible with 1.6.0, that's why we use Semantic Versioning :-) – Dennis Doomen Jan 27 '12 at 11:50
  • Good to know! It's still not my decision, but it'll be easier to convince the project manager =) – Tomas Aschan Jan 27 '12 at 13:32