public void ChildRemoved_EventArgsAndSenderCorrect() { int pos = 1; TreeNode removedChild = mRootNode.RemoveChild(pos); Assert.AreSame( mRootNode, mLatestChildRemovedSender, "The sender of the ChildRemoved event must be the TreeNode from which the the child was removed"); Assert.AreSame( removedChild, mLatestChildRemovedEventArgs.m_RemovedObject, "The RemovedChild member of the child removed event args must be the child that was removed"); Assert.AreEqual( pos, mLatestChildRemovedEventArgs.m_RemovedObjectPosition, "The RemovedPosition member of the child removed event args must be the position of the child before it was removed"); removedChild.Children.ObjectRemoved += mTreeNode_childRemoved; pos = removedChild.Children.Count - 1; TreeNode removedChild2 = removedChild.RemoveChild(pos); Assert.AreSame( removedChild, mLatestChildRemovedSender, "The sender of the ChildRemoved event must be the TreeNode from which the the child was removed"); Assert.AreSame( removedChild2, mLatestChildRemovedEventArgs.m_RemovedObject, "The RemovedChild member of the child removed event args must be the child that was removed"); Assert.AreEqual( pos, mLatestChildRemovedEventArgs.m_RemovedObjectPosition, "The RemovedPosition member of the child removed event args must be the position of the child before it was removed"); }
public void ChildRemoved_EventOccursAndBubble() { int beforeCount; int changedBeforeCount; beforeCount = mChildRemovedEventCount; changedBeforeCount = mChangedEventCount; TreeNode removedChild = mRootNode.RemoveChild(1); AssertChildRemovedEventOccured(beforeCount, changedBeforeCount); beforeCount = mChildRemovedEventCount; changedBeforeCount = mChangedEventCount; removedChild.Children.ObjectRemoved += mTreeNode_childRemoved; removedChild.Changed += new EventHandler <urakawa.events.DataModelChangedEventArgs>(mTreeNode_changed); try { removedChild.RemoveChild(removedChild.Children.Get(removedChild.Children.Count - 1)); AssertChildRemovedEventOccured(beforeCount, changedBeforeCount); } finally { removedChild.Children.ObjectRemoved -= mTreeNode_childRemoved; removedChild.Changed -= new EventHandler <urakawa.events.DataModelChangedEventArgs>(mTreeNode_changed); } }