コード例 #1
0
        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);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }
コード例 #8
0
		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);
		}
コード例 #9
0
		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);
		}
コード例 #10
0
        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);
        }
コード例 #11
0
		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);
		}
コード例 #12
0
 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);
 }