Пример #1
0
        public void addNodeTest_duplicateNode_throwError()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(1);
            myBST.addNode(1);
            //assert
        }
Пример #2
0
        public void getHeightTest_TwoNode_ReturnTwo()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(1);
            myBST.addNode(2);
            //assert
            Assert.AreEqual(2, myBST.getHeight());
        }
Пример #3
0
        public void nodeExistsTest_AddNode_ReturnTrue()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(1);
            myBST.addNode(3);
            myBST.addNode(2);
            myBST.addNode(4);
            //assert
            Assert.AreEqual(true, myBST.nodeExists(1));
        }
Пример #4
0
        public void deleteNodeTest_SingleInt_Returnint()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(1);
            myBST.addNode(2);
            myBST.addNode(3);
            myBST.addNode(4);
            int testDeleteNoteVal = myBST.deleteNode(4);

            //assert
            Assert.AreEqual(4, testDeleteNoteVal);
        }
Пример #5
0
        public void deleteNodeTest_NodeThatDoesNotExist_throwError()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(2);
            myBST.deleteNode(1);
            //assert
        }
Пример #6
0
        public void addNodeTest_singleNode_returnNode()
        {
            //arrange
            var myBST = new binarySearchTree <int>();
            //act
            int myTestInt = myBST.addNode(1).val;

            //assert
            Assert.AreEqual(1, myTestInt);
        }
Пример #7
0
        public void postOrder_Test_Returninorder()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(4);
            myBST.addNode(2);
            myBST.addNode(6);
            myBST.addNode(1);
            myBST.addNode(3);
            myBST.addNode(5);
            myBST.addNode(7);
            int[] myArray = new int[] { 4, 2, 1, 3, 6, 5, 7 };
            //assert
            Assert.AreEqual(myArray, myBST.postOrderTraversal());
        }
Пример #8
0
        public void breadthFirstSearch_Test_ReturnBreadthFirstStructure()
        {
            //arrange
            var myBST = new binarySearchTree <int>();

            //act
            myBST.addNode(4);
            myBST.addNode(2);
            myBST.addNode(6);
            myBST.addNode(1);
            myBST.addNode(3);
            myBST.addNode(5);
            myBST.addNode(7);
            int[] myArray = new int[] { 4, 2, 6, 1, 3, 5, 7 };
            //assert
            Assert.AreEqual(myArray, myBST.breadthFirstSearch());
        }