1

I have two lists (of objects, but later selected just into "Name" strings) and I'm using Fluent Assertions to compare that they should contain the same items. This is easily enough achieved through the Collection Assertions, such as .Equal or .BeEquivalentTo. However the error message just says something to the effect of List two { "string 1", "string 2", ... 31 more } should be equal to List one { "string 1", "string 2", ... 32 more } but contains 1 more item.

I was wondering if this message could be configured to include the missing item?

Since I'm working with strings, I could shift my approach to

list1.Except(list2).Should().BeEmpty();

and the message will include the extra item (or missing, if I flip the Except around. I could assert both directions if needed, but in my case only one is needed). But the beauty of the .BeEquivalentTo() and .ContainEquivalentOf() comparisons is the flexibility, so I'd like to know if they could be configured to show details about the missing/extra item?

gakera
  • 3,589
  • 4
  • 30
  • 36

0 Answers0