public void Compare_List_As_Deep_Compare_With_Default()
{
SutEngine.Configure<NestedListWithDefault>()
.For(x => x.Children, x => x.MatchUsing(y => y.Id, -1));
var oldModel = new NestedListWithDefault()
{
Children = new List<GrandChildModel>()
{
new GrandChildModel()
{
Id = 100,
Name = "Name 1",
Value = 100
},
}
};
var newModel = new NestedListWithDefault()
{
Children = new List<GrandChildModel>()
{
new GrandChildModel()
{
Id = 100,
Name = "Name 1",
Value = 100
},
new GrandChildModel()
{
Id = -1,
Name = "Name 2",
Value = 200
},
new GrandChildModel()
{
Id = -1,
Name = "Name 3",
Value = 300
},
new GrandChildModel()
{
Id = -1,
Name = "Name 4",
Value = 400
},
}
};
var changes = SutEngine.Compare(oldModel, newModel);
Assert.AreEqual(changes.Count(), 9);
Assert.IsNotNull(changes.Count(x => x.Name == "Children.0.Id" && (long)x.NewValue == 0) == 3);
}