public void EnsureRemovedAndRemovingEventFiredForParentAndAllChildNodes() { workingNode = new TestConfigurationNode("B"); node.AddNode(workingNode); workingNode.Removed += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoved); workingNode.Removing += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoving); TestConfigurationNode workingChildNode = new TestConfigurationNode("working child"); workingNode.AddNode(workingChildNode); workingChildNode.Removed += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoved); workingChildNode.Removing += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoving); workingNode.Remove(); Assert.IsFalse(node.Nodes.Contains(workingNode)); ConfigurationNode match = null; foreach (ConfigurationNode childNode in node.Nodes) { if (childNode == workingNode) { match = childNode; } } Assert.IsNull(match); Assert.AreEqual(2, removeEventCount); workingNode.Removed -= new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoved); workingNode.Removing -= new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoving); workingChildNode.Removed -= new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoved); workingChildNode.Removing -= new EventHandler <ConfigurationNodeChangedEventArgs>(NodeRemoving); }
public void ChildRemovedTest() { node.ChildRemoved += new ConfigurationNodeChangedEventHandler(NodeChildRemoved); workingNode = new TestConfigurationNode("New Node"); node.AddNode(workingNode); workingNode.Remove(); Assert.AreEqual(1, removeChildEventCount); node.ChildRemoved -= new ConfigurationNodeChangedEventHandler(NodeChildRemoved); }
public void RemoveNodeLeavesOnlyOneNodeInChildNodeArray() { TestConfigurationNode nodeA = new TestConfigurationNode("A"); TestConfigurationNode nodeB = new TestConfigurationNode("B"); node.AddNode(nodeA); node.AddNode(nodeB); nodeA.Remove(); Assert.AreEqual(1, node.Nodes.Count); }
public void EnsureParentNodeNotifiedOfChildRemovedAndRemovingEvent() { node.ChildRemoving += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoving); node.ChildRemoved += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoved); workingNode = new TestConfigurationNode("Test"); node.AddNode(workingNode); workingNode.Remove(); Assert.AreEqual(1, removeChildEventCount); Assert.AreEqual(1, removingChildEventCount); node.ChildRemoved -= new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoved); node.ChildRemoving -= new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoving); }
public void EnsureRemovingAParentNodeChildNodeDoesNotNotifyParent() { TestConfigurationNode testNode = new TestConfigurationNode("Test"); testNode.ChildRemoving += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoving); testNode.ChildRemoved += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoved); testNode.AddNode(new TestConfigurationNode("A")); testNode.AddNode(new TestConfigurationNode("B")); node.AddNode(testNode); testNode.Remove(); Assert.AreEqual(0, removeChildEventCount); Assert.AreEqual(0, removingChildEventCount); testNode.ChildRemoving += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoving); testNode.ChildRemoved += new EventHandler <ConfigurationNodeChangedEventArgs>(NodeChildRemoved); }
public void RemovedTest() { workingNode = new TestConfigurationNode("New Node"); node.AddNode(workingNode); workingNode.Removed += new ConfigurationNodeChangedEventHandler(WorkingNodeRemoved); workingNode.Remove(); Assert.IsFalse(node.Nodes.Contains(workingNode)); ConfigurationNode match = null; foreach (ConfigurationNode childNode in node.Nodes) { if (childNode == workingNode) { match = childNode; } } Assert.IsNull(match); Assert.AreEqual(1, removeEventCount); workingNode.Removed -= new ConfigurationNodeChangedEventHandler(WorkingNodeRemoved); }
public void EnsureRemovedAndRemovingEventFiredForParentAndAllChildNodes() { workingNode = new TestConfigurationNode("B"); node.AddNode(workingNode); workingNode.Removed += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoved); workingNode.Removing += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoving); TestConfigurationNode workingChildNode = new TestConfigurationNode("working child"); workingNode.AddNode(workingChildNode); workingChildNode.Removed += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoved); workingChildNode.Removing += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoving); workingNode.Remove(); Assert.IsFalse(node.Nodes.Contains(workingNode)); ConfigurationNode match = null; foreach (ConfigurationNode childNode in node.Nodes) { if (childNode == workingNode) { match = childNode; } } Assert.IsNull(match); Assert.AreEqual(2, removeEventCount); workingNode.Removed -= new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoved); workingNode.Removing -= new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoving); workingChildNode.Removed -= new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoved); workingChildNode.Removing -= new EventHandler<ConfigurationNodeChangedEventArgs>(NodeRemoving); }
public void EnsureRemovingAParentNodeChildNodeDoesNotNotifyParent() { TestConfigurationNode testNode = new TestConfigurationNode("Test"); testNode.ChildRemoving += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoving); testNode.ChildRemoved += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoved); testNode.AddNode(new TestConfigurationNode("A")); testNode.AddNode(new TestConfigurationNode("B")); node.AddNode(testNode); testNode.Remove(); Assert.AreEqual(0, removeChildEventCount); Assert.AreEqual(0, removingChildEventCount); testNode.ChildRemoving += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoving); testNode.ChildRemoved += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoved); }
public void EnsureParentNodeNotifiedOfChildRemovedAndRemovingEvent() { node.ChildRemoving += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoving); node.ChildRemoved += new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoved); workingNode = new TestConfigurationNode("Test"); node.AddNode(workingNode); workingNode.Remove(); Assert.AreEqual(1, removeChildEventCount); Assert.AreEqual(1, removingChildEventCount); node.ChildRemoved -= new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoved); node.ChildRemoving -= new EventHandler<ConfigurationNodeChangedEventArgs>(NodeChildRemoving); }