I am using Fluent Assertions and willing to test if my collection contains some object using deep object graph comparison. I don't want to implement all that equality members. However, I can not find the way to do the test for equivalence containment of some object in the collection. For example, this test fails and I want it to pass:
class Student
{
public string Name { get; set; }
}
[Test]
public void ShouldContainStudent()
{
new[] { new Student { Name = "George" }, new Student { Name = "Anna" } }.Should()
.Contain(new Student { Name = "Anna" });
}
Is there some elegant way to do it? Something like this?
[Test]
public void ShouldContainStudent()
{
new[] { new Student { Name = "George" }, new Student { Name = "Anna" } }.ShouldContainEquivalent(new Student { Name = "Anna" });
}