public void BeginEdit_merge_changes_set_collection_for_many_to_x_navigation_property() { MockEntity entity = new MockEntity(); entity.BeginEdit(); MockAssociativeEntity associativeEntity = new MockAssociativeEntity(); associativeEntity.BeginEdit(); associativeEntity.IntProperty = 2; entity.AssociativeEntities = new HashSet <MockAssociativeEntity>() { associativeEntity }; associativeEntity.BoolProperty = true; Assert.AreEqual(3, entity.PropertyChanges().Count()); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".AssociativeEntities"))); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".AssociativeEntities[Guid=" + associativeEntity.Guid + "].IntProperty"))); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".AssociativeEntities[Guid=" + associativeEntity.Guid + "].BoolProperty"))); Should.Throw <ArgumentNullException>(() => associativeEntity.DbEntityChanges()); Assert.IsTrue(entity.IsTracked); Assert.IsTrue(entity.IsEditing); Assert.IsTrue(associativeEntity.IsTracked); Assert.IsFalse(associativeEntity.IsEditing); }
public void BeginEdit_merge_changes_one_to_many_navigation_property() { MockEntity entity = new MockEntity(); entity.BeginEdit(); MockEntity relationalEntity = new MockEntity(); relationalEntity.BeginEdit(); relationalEntity.RelationalEntity1 = new MockEntity(); relationalEntity.RelationalEntity1.StringProperty = "Address Line 1"; entity.RelationalEntity1 = relationalEntity; relationalEntity.IntProperty = 1; Assert.AreEqual(4, entity.PropertyChanges().Count()); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".RelationalEntity1"))); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".RelationalEntity1.RelationalEntity1"))); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".RelationalEntity1.RelationalEntity1.StringProperty"))); Assert.IsTrue(entity.PropertyChanges().Any(c => c.DbEntityPropertyPath(entity).Equals(".RelationalEntity1.IntProperty"))); Should.Throw <ArgumentNullException>(() => relationalEntity.DbEntityChanges()); Assert.IsTrue(entity.IsTracked); Assert.IsTrue(entity.IsEditing); Assert.IsTrue(relationalEntity.IsTracked); Assert.IsFalse(relationalEntity.IsEditing); }