public void ObjectMapConfig_Map_CollectionElementMapMode_DeepCopy_Implement_Interface() { var config = new ObjectMapConfig(); config.CollectionElementMapMode = CollectionElementMapMode.DeepCopy; var u1 = new UserListInfoWithInterface(); var u2 = new UserListInfoWithInterface_SubClass(); for (int i = 0; i < 3; i++) { u1.Users.Add(new VipUser("TestUser" + i.ToString())); } config.Map(u1, u2); u1.Users[0].Name = "Test20"; Assert.AreEqual(3, u2.Users.Count); Assert.AreEqual("Test20", u2.Users[0].Name); }
public void ObjectMapper_Map_CollectionElementCreateMode_DeepCopy_Implement_Interface() { var mapper = new ObjectMapper(); mapper.CompilerConfig.CollectionElementCreateMode = CollectionElementCreateMode.Assign; var u1 = new UserListInfoWithInterface(); var u2 = new UserListInfoWithInterface_SubClass(); for (int i = 0; i < 3; i++) { u1.Users.Add(new VipUser("TestUser" + i.ToString())); } mapper.Map(u1, u2); u1.Users[0].Name = "Test20"; Assert.AreEqual(3, u2.Users.Count); Assert.AreEqual("Test20", u2.Users[0].Name); }