public void AddingSameNodeToCollectionThrows()
		{
			TestConfigurationNode testNode = new TestConfigurationNode("Foo");
			TestConfigurationNode node1 = new TestConfigurationNode("Node");
			testNode.AddNode(node1);
			testNode.AddNode(node1);
		}
Exemplo n.º 2
0
        public void AddingSameNodeToCollectionThrows()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Foo");
            TestConfigurationNode node1    = new TestConfigurationNode("Node");

            testNode.AddNode(node1);
            testNode.AddNode(node1);
        }
Exemplo n.º 3
0
        public void MoveNodeAfterSiblingWithNullSiblingNodeThrows()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            testNode.MoveAfter(testNode.Nodes[0], null);
        }
Exemplo n.º 4
0
        public void MoveNodeBeforeSiblingPositionWithNullSiblingNodeThrows()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            testNode.MoveBefore(testNode.Nodes[2], null);
        }
Exemplo n.º 5
0
 public void CanGetNextSiblingNode()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.AddNode(new TestConfigurationNode("ATest"));
     testNode.AddNode(new TestConfigurationNode("CTest"));
     ConfigurationNode firstNode = (ConfigurationNode)testNode.Nodes[0];
     Assert.AreEqual("ATest", firstNode.NextSibling.Name);
 }
Exemplo n.º 6
0
        public void MoveBeforeTestWithNullSiblingNode()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            CreateHierarchyAndAddToHierarchyService(testNode, CreateDefaultConfiguration());
            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            testNode.MoveBefore(testNode.ChildNodes[2], null);
        }
Exemplo n.º 7
0
        public void RenameAChildNodeWithTheSameNameNotInAContainer()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Root");

            testNode.AddNode(new TestConfigurationNode("Test"));
            TestConfigurationNode nameNode = new TestConfigurationNode("Test1");

            testNode.AddNode(nameNode);
            nameNode.Name = "Test";
        }
Exemplo n.º 8
0
 public void CanMoveNodeAfterSiblingNode()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.AddNode(new TestConfigurationNode("ATest"));
     testNode.AddNode(new TestConfigurationNode("CTest"));
     ConfigurationNode nodeA = (ConfigurationNode)testNode.Nodes[1];
     testNode.MoveAfter(testNode.Nodes[0], nodeA);
     Assert.AreEqual("BTest", nodeA.NextSibling.Name);
 }
Exemplo n.º 9
0
        public void LastNodeIsTheLastChildAdded()
        {
            TestConfigurationNode node       = new TestConfigurationNode("test");
            TestConfigurationNode firstChild = new TestConfigurationNode("firstchild");
            TestConfigurationNode lastChild  = new TestConfigurationNode("lastchild");

            node.AddNode(firstChild);
            node.AddNode(lastChild);
            Assert.AreSame(lastChild, node.LastNode);
        }
Exemplo n.º 10
0
        public void PreviousSiblingTest()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode lastNode = (ConfigurationNode)testNode.Nodes[2];

            Assert.AreEqual("ATest", lastNode.PreviousSibling.Name);
        }
Exemplo n.º 11
0
        public void CanGetNextSiblingNode()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode firstNode = (ConfigurationNode)testNode.Nodes[0];

            Assert.AreEqual("ATest", firstNode.NextSibling.Name);
        }
Exemplo n.º 12
0
        public void PreviousSiblingTest()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            CreateHierarchyAndAddToHierarchyService(testNode, CreateDefaultConfiguration());
            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode lastNode = testNode.ChildNodes[2];

            Assert.AreEqual("ATest", lastNode.PreviousSibling.Name);
        }
        public void CanMoveNodeAfterSiblingNode()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode nodeA = (ConfigurationNode)testNode.Nodes[1];

            testNode.MoveAfter(testNode.Nodes[0], nodeA);
            Assert.AreEqual("BTest", nodeA.NextSibling.Name);
        }
Exemplo n.º 14
0
        public void CanMoveNodeBeforePreviousSiblingPosition()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode nodeA = (ConfigurationNode)testNode.Nodes[1];

            testNode.MoveBefore(testNode.Nodes[2], nodeA);
            Assert.AreEqual("CTest", nodeA.PreviousSibling.Name);
        }
Exemplo n.º 15
0
        public void MoveBeforeTest()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            CreateHierarchyAndAddToHierarchyService(testNode, CreateDefaultConfiguration());
            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode nodeA = testNode.ChildNodes[1];

            testNode.MoveBefore(testNode.ChildNodes[2], nodeA);
            Assert.AreEqual("CTest", nodeA.PreviousSibling.Name);
        }
Exemplo n.º 16
0
        public void MoveNodeBeforeSiblingWithNullParentThrows()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.MoveBefore(testNode.Nodes[0], new TestConfigurationNode("Not A Child"));
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
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);
        }
Exemplo n.º 19
0
        public void EnsureCanAddNodesWithNoHierarchySet()
        {
            TestConfigurationNode myNode = new TestConfigurationNode("Root");

            myNode.AddNode(new TestConfigurationNode("Child"));

            Assert.AreEqual(1, myNode.Nodes.Count);
            Assert.IsNull(myNode.Hierarchy);
        }
Exemplo n.º 20
0
        public void MoveNodeBeforeSiblingWithDifferentParrent()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            TestConfigurationNode testNode2 = new TestConfigurationNode("Test2");

            testNode2.AddNode(new TestConfigurationNode("ATest"));
            testNode.MoveBefore(testNode2.Nodes[0], testNode.Nodes[0]);
        }
Exemplo n.º 21
0
        public void CanMoveNodeAfterSiblingNode()
        {
            TestConfigurationNode testNode = new TestConfigurationNode("Test");

            testNode.AddNode(new TestConfigurationNode("BTest"));
            testNode.AddNode(new TestConfigurationNode("ATest"));
            testNode.AddNode(new TestConfigurationNode("CTest"));
            ConfigurationNode nodeA = (ConfigurationNode)testNode.Nodes[1];

            testNode.MoveAfter(testNode.Nodes[0], nodeA);
            Assert.AreEqual("BTest", nodeA.NextSibling.Name);

            string[] expectedNames = new string[] { "ATest", "BTest", "CTest" };
            Assert.AreEqual(expectedNames.Length, testNode.Nodes.Count);
            for (int i = 0; i < expectedNames.Length; ++i)
            {
                Assert.AreEqual(expectedNames[i], testNode.Nodes[i].Name);
            }
        }
Exemplo n.º 22
0
        public void EnsureHierarchySetWhenAddingToNodeWithHierarchy()
        {
            TestConfigurationNode myNode    = new TestConfigurationNode("Child1");
            TestConfigurationNode childNode = new TestConfigurationNode("Child2");

            myNode.AddNode(childNode);
            node.AddNode(myNode);

            Assert.IsNotNull(myNode.Hierarchy);
            Assert.AreSame(hierarchy, myNode.Hierarchy);
            Assert.IsNotNull(childNode.Hierarchy);
            Assert.AreSame(hierarchy, childNode.Hierarchy);
        }
 public void MoveNodeBeforeSiblingWithNullParentThrows()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.MoveBefore(testNode.Nodes[0], new TestConfigurationNode("Not A Child"));
 }
Exemplo n.º 24
0
 public void PreviousSiblingTest()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     CreateHierarchyAndAddToHierarchyService(testNode, CreateDefaultConfiguration());
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.AddNode(new TestConfigurationNode("ATest"));
     testNode.AddNode(new TestConfigurationNode("CTest"));
     ConfigurationNode lastNode = testNode.ChildNodes[2];
     Assert.AreEqual("ATest", lastNode.PreviousSibling.Name);
 }
 public void RenameAChildNodeWithTheSameNameNotInAContainer()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Root");
     testNode.AddNode(new TestConfigurationNode("Test"));
     TestConfigurationNode nameNode = new TestConfigurationNode("Test1");
     testNode.AddNode(nameNode);
     nameNode.Name = "Test";
 }
        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 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 EnsureCanAddNodesWithNoHierarchySet()
		{
			TestConfigurationNode myNode = new TestConfigurationNode("Root");
			myNode.AddNode(new TestConfigurationNode("Child"));

			Assert.AreEqual(1, myNode.Nodes.Count);
			Assert.IsNull(myNode.Hierarchy);
		}
		public void EnsureHierarchySetWhenAddingToNodeWithHierarchy()
		{

			TestConfigurationNode myNode = new TestConfigurationNode("Child1");
			TestConfigurationNode childNode = new TestConfigurationNode("Child2");
			myNode.AddNode(childNode);
			node.AddNode(myNode);

			Assert.IsNotNull(myNode.Hierarchy);
			Assert.AreSame(hierarchy, myNode.Hierarchy);
			Assert.IsNotNull(childNode.Hierarchy);
			Assert.AreSame(hierarchy, childNode.Hierarchy);
		}
		public void PreviousSiblingTest()
		{
			TestConfigurationNode testNode = new TestConfigurationNode("Test");			
			testNode.AddNode(new TestConfigurationNode("BTest"));
			testNode.AddNode(new TestConfigurationNode("ATest"));
			testNode.AddNode(new TestConfigurationNode("CTest"));
			ConfigurationNode lastNode = (ConfigurationNode)testNode.Nodes[2];
			Assert.AreEqual("ATest", lastNode.PreviousSibling.Name);
		}
		public void MoveNodeAfterSiblingWithNullSiblingNodeThrows()
		{
			TestConfigurationNode testNode = new TestConfigurationNode("Test");			
			testNode.AddNode(new TestConfigurationNode("BTest"));
			testNode.AddNode(new TestConfigurationNode("ATest"));
			testNode.AddNode(new TestConfigurationNode("CTest"));
			testNode.MoveAfter(testNode.Nodes[0], null);
		}
		public void CanMoveNodeBeforePreviousSiblingPosition()
		{
			TestConfigurationNode testNode = new TestConfigurationNode("Test");			
			testNode.AddNode(new TestConfigurationNode("BTest"));
			testNode.AddNode(new TestConfigurationNode("ATest"));
			testNode.AddNode(new TestConfigurationNode("CTest"));
			ConfigurationNode nodeA = (ConfigurationNode)testNode.Nodes[1];
			testNode.MoveBefore(testNode.Nodes[2], nodeA);
			Assert.AreEqual("CTest", nodeA.PreviousSibling.Name);
		}
 public void MoveNodeBeforeSiblingPositionWithNullSiblingNodeThrows()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.AddNode(new TestConfigurationNode("ATest"));
     testNode.AddNode(new TestConfigurationNode("CTest"));
     testNode.MoveBefore(testNode.Nodes[2], null);
 }
Exemplo n.º 34
0
 public void MoveNodeAfterWithNullSiblingNode()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     CreateHierarchyAndAddToHierarchyService(testNode, CreateDefaultConfiguration());
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.AddNode(new TestConfigurationNode("ATest"));
     testNode.AddNode(new TestConfigurationNode("CTest"));
     testNode.MoveAfter(testNode.ChildNodes[0], null);
 }
		public void LastNodeIsTheLastChildAdded()
		{
			TestConfigurationNode node = new TestConfigurationNode("test");			
			TestConfigurationNode firstChild = new TestConfigurationNode("firstchild");
			TestConfigurationNode lastChild = new TestConfigurationNode("lastchild");
			node.AddNode(firstChild);
			node.AddNode(lastChild);
			Assert.AreSame(lastChild, node.LastNode);
		}
 public void MoveNodeBeforeSiblingWithDifferentParrent()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     testNode.AddNode(new TestConfigurationNode("BTest"));
     TestConfigurationNode testNode2 = new TestConfigurationNode("Test2");
     testNode2.AddNode(new TestConfigurationNode("ATest"));
     testNode.MoveBefore(testNode2.Nodes[0], testNode.Nodes[0]);
 }
Exemplo n.º 37
0
 public void MoveBeforeTest()
 {
     TestConfigurationNode testNode = new TestConfigurationNode("Test");
     CreateHierarchyAndAddToHierarchyService(testNode, CreateDefaultConfiguration());
     testNode.AddNode(new TestConfigurationNode("BTest"));
     testNode.AddNode(new TestConfigurationNode("ATest"));
     testNode.AddNode(new TestConfigurationNode("CTest"));
     ConfigurationNode nodeA = testNode.ChildNodes[1];
     testNode.MoveBefore(testNode.ChildNodes[2], nodeA);
     Assert.AreEqual("CTest", nodeA.PreviousSibling.Name);
 }