Пример #1
0
        public void Test_Find_For_Empty_Tree()
        {
            // Arrange
            BinaryTree bt = new BinaryTree();

            // Act
            Data data = bt.FindNode(7);   // Should be no node to find...

            // Assert
            Assert.IsNull(data);
        }
Пример #2
0
        public void Test_Find_Succeeds_For_Single_Node_Tree()
        {
            // Arrange
            BinaryTree bt = new BinaryTree();
            Data data = new Data();
            bt.Insert(17, data);

            // Act
            data = bt.FindNode(17);   // Should find the single node (17 == 17)...

            // Assert
            Assert.IsNotNull(data);
        }
Пример #3
0
        public void Test_Find_On_Non_Existant_Key_Fails_For_Single_Node_Tree()
        {
            // Arrange
            BinaryTree bt = new BinaryTree();
            Data data = new Data();
            bt.Insert(17, data);

            // Act
            data = bt.FindNode(23);   // Should be no node to find (23 != 17)...

            // Assert
            Assert.IsNull(data);
        }
Пример #4
0
        public void Test_Find_Succeeds_When_Searching_A_Depth_Equals_2_Tree()
        {
            // Arrange
            BinaryTree bt = new BinaryTree();
            BuildLeftUnbalancedTree(bt);
            Data data = new Data(17, "Data4");
            bt.Insert(17,data);   // Tree (should have a depth of two, new leaf node.

            // Act
            data = bt.FindNode(17);   // Should find the single node (17 == 17)...

            // Assert
            Assert.IsNotNull(data);
        }
Пример #5
0
        public void Test_Find_Succeeds_When_Walking_Complex_Tree()
        {
            // Arrange
            BinaryTree bt = new BinaryTree();
            BuildSevenNodeBalancedTree(bt);
            int iVal = 9;  // Internal Node in tree...

            // Act
            Data data = bt.FindNode(iVal);   // Should find the single node (17 == 17)...

            // Assert
            Assert.IsNotNull(data);
        }