I want to compare a list of objects, ignoring the order of the objects in the list and only comparing some of the properties in the objects, currently I'm using the following code to perform this comparison:
actual.Should().NotBeNull();
actual.Count.Should().Be(expected.Count);
//compare ignoring order
foreach (var exp in expected)
actual.Should().Contain(act =>
act.IndividualId.Equals(exp.IndividualId)
&& act.Email.Equals(exp.Email)
&& act.FirstName.Equals(exp.FirstName)
&& act.LastName.Equals(exp.LastName)
);
However this seems less than ideal, as when there is a failure you do not get a print out of the expected values. Is there a built in mechanism for performing this comparison using fluent assertions?