-
Notifications
You must be signed in to change notification settings - Fork 725
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Hello!
When a type is a collection the comparison seems to ignore all other type members. Is this by design or am I missing here something? What would be the recommended workaround for now? I'm using version 5.3.2
.
public class FluentAssertionsTests
{
public class CollectionA : List<ObjectA>
{
public int Y { get; set; }
}
public class ObjectA
{
public int X { get; set; }
}
[Fact]
public void ThisFailsAsExpected()
{
var a1 = new ObjectA();
var a2 = new ObjectA();
a1.X = 1;
a2.X = 2;
a1.Should().BeEquivalentTo(a2);
}
[Fact]
public void ThisShouldFailButSucceeds()
{
var a1 = new CollectionA {new ObjectA {X = 1}};
var a2 = new CollectionA {new ObjectA {X = 1}};
a1.Y = 1;
a2.Y = 2;
a1.Should().BeEquivalentTo(a2);
}
}
Thanks :)
Rutgerz