Exemplo n.º 1
0
        public void RemoveChildTest()
        {
            // Parent node
            HeapNode <float, string> node = new HeapNode <float, string>(0, "Potato");

            // Add and remove child
            HeapNode <float, string> child = new HeapNode <float, string>(2, "Tomato");

            node.AddChild(child);
            node.RemoveChild(child);

            Assert.IsNull(child.Parent);                    // Child has no parent
            Assert.AreEqual(node.Children.Count, 0);        // Node has no children
            Assert.IsFalse(node.Children.Contains(child));  // Child is not a child of node
            Assert.AreEqual(node.Rank, 0);                  // Rank reflects number of children
        }