Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top