public void RootChildListUndoCancel() { EditableGetSet root = new EditableGetSet(); Assert.AreEqual(0, root.EditLevel, "Root edit level before BeginEdit"); root.BeginEdit(); Assert.AreEqual(1, root.EditLevel, "Root edit level after BeginEdit"); ChildList list = root.ManagedChildList; Assert.AreEqual(1, list.EditLevel, "List edit level after being created"); Assert.IsFalse(root.IsDirty, "Root should not be dirty"); Assert.IsFalse(list.IsDirty, "List should not be dirty"); list.Add(new EditableGetSet(true)); Assert.AreEqual(1, list.Count, "List count should be 1"); root.CancelEdit(); Assert.AreEqual(0, root.EditLevel, "Root edit level after CancelEdit"); ChildList secondList = root.ManagedChildList; Assert.AreEqual(0, secondList.EditLevel, "Second list edit level after CancelEdit"); Assert.IsFalse(ReferenceEquals(list, secondList), "List objects should not be the same"); Assert.IsFalse(root.IsDirty, "Root should not be dirty after CancelEdit"); Assert.IsFalse(secondList.IsDirty, "Second list should not be dirty"); }
public void RootChildListUndoCancel() { IDataPortal <EditableGetSet> dataPortal = _testDIContext.CreateDataPortal <EditableGetSet>(); IChildDataPortal <EditableGetSet> childDataPortal = _testDIContext.CreateChildDataPortal <EditableGetSet>(); EditableGetSet root = EditableGetSet.GetObject(dataPortal); Assert.AreEqual(0, root.EditLevel, "Root edit level before BeginEdit"); root.BeginEdit(); Assert.AreEqual(1, root.EditLevel, "Root edit level after BeginEdit"); ChildList list = root.ManagedChildList; Assert.AreEqual(1, list.EditLevel, "List edit level after being created"); Assert.IsFalse(root.IsDirty, "Root should not be dirty"); Assert.IsFalse(list.IsDirty, "List should not be dirty"); list.Add(EditableGetSet.NewChildObject(childDataPortal)); Assert.AreEqual(1, list.Count, "List count should be 1"); root.CancelEdit(); Assert.AreEqual(0, root.EditLevel, "Root edit level after CancelEdit"); ChildList secondList = root.ManagedChildList; Assert.AreEqual(0, secondList.EditLevel, "Second list edit level after CancelEdit"); Assert.IsFalse(ReferenceEquals(list, secondList), "List objects should not be the same"); Assert.IsFalse(root.IsDirty, "Root should not be dirty after CancelEdit"); Assert.IsFalse(secondList.IsDirty, "Second list should not be dirty"); }