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

Commented Unassigned: Collection should contain other collection behaving unexpectedly [12495]

$
0
0
I want to assert that a collection of simple objects includes a smaller collection of the same object type. For some reason actualCollection.Should().Contain(expectedCollection) is failing with a message that shows all of the expected objects are in the actual collection but it's claiming that they aren't.

Here's the assertion failure output I'm getting:
```
Expected collection {
ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "custom"
percentage = 0.333333333333333
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "friends"
percentage = 0
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "friends of friends"
percentage = 0.333333333333333
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "only me"
percentage = 0
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "public"
percentage = 0.333333333333333
}} to contain {

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "custom"
percentage = 0.333333333333333
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "friends of friends"
percentage = 0.333333333333333
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "public"
percentage = 0.333333333333333
}}, but could not find {

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "custom"
percentage = 0.333333333333333
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "friends of friends"
percentage = 0.333333333333333
},

ActivityServiceTest.DataTypes.SocialItemSummary
{
category = "public"
percentage = 0.333333333333333
}}
```
Comments: Why would it use reference equality when it can print out this perfect textual comparison that clearly shows object equality? I shouldn't need to implement an Equals method for simple objects like this where the FluentAssertion was capable of perfectly representing the object in textual form.

Viewing all articles
Browse latest Browse all 1402

Trending Articles