Is there a way to assert the equivalency of two lists of objects by properties located in a nested list? I know you can test equivalency with ShouldAllBeEquivalentTo() and Include() only certain properties, but I would like to call Include() on a property defined in a nested list:
class A
{
public B[] List { get; set; }
public string SomePropertyIDontCareAbout { get; set; }
}
class B
{
public string PropertyToInclude { get; set; }
public string SomePropertyIDontCareAbout { get; set; }
}
var list1 = new[]
{
new A
{
List = new[] {new B(), new B()}
},
};
var list2 = new[]
{
new A
{
List = new[] {new B(), new B()}
},
};
list1.ShouldAllBeEquivalentTo(list2, options => options
.Including(o => o.List.Select(l => l.PropertyToInclude))); // doesn't work