I have two classes:
public class ClassA
{
public int? ID {get; set;}
public IEnumerable<ClassB> Children {get; set;}
}
public class ClassB
{
public int? ID {get; set;}
public string Name {get; set;}
}
I want to use fluent assertions to compare to ClassA instances. However I want to ignore the IDs (because the IDs will have been assigned after the save).
I know I can do this:
expectedA.ShouldBeEquivalentTo(actualA, options => options.Excluding(x => x.PropertyPath == "Children[0].ID"));
Which I can obviously repeat for each ClassB in the collection. However I'm looking for a way to exclude the all the IDs (rather than doing an exclude for each element).
I've read this question however if I remove the [0] indexers the assertions fail.
Is this possible?