Пример #1
0
        public void Can_Add_Multiple_To_BST_Test()
        {
            //arrange
            BinarySearchTree myTree = new BinarySearchTree();

            //act
            myTree.add(10);
            myTree.add(5);

            //Assert
            Assert.Equal(5, myTree.Root.Left.Value);
        }
Пример #2
0
        public void Finding_Max_Value_Test()
        {
            //arrange
            BinarySearchTree myTree = new BinarySearchTree();

            myTree.add(10);
            myTree.add(5);
            myTree.add(4);
            myTree.add(13);

            //act
            int actual = myTree.FindMaxValue();

            //Assert
            Assert.Equal(13, actual);
        }
Пример #3
0
        public void Contains_Test()
        {
            //arrange
            BinarySearchTree myTree = new BinarySearchTree();

            myTree.add(10);
            myTree.add(5);
            myTree.add(4);
            myTree.add(13);

            //act
            bool actual = myTree.Contains(13);

            //Assert
            Assert.True(actual);
        }
Пример #4
0
        public void PostOrder_Test()
        {
            //arrange
            BinarySearchTree myTree = new BinarySearchTree();

            myTree.add(10);
            myTree.add(5);
            myTree.add(4);
            myTree.add(13);
            int[] expected = new int[] { 4, 5, 13, 10 };

            //act
            int[] actual = myTree.DepthHandler("postorder");

            //Assert
            Assert.Equal(expected, actual);
        }
Пример #5
0
        public void Breadth_Travesal_Test()
        {
            //arrange
            BinarySearchTree myTree = new BinarySearchTree();

            myTree.add(10);
            myTree.add(5);
            myTree.add(4);
            myTree.add(13);
            int[] expected = new int[] { 10, 5, 13, 4 };

            //act
            List <int> actual = myTree.Breadth();

            //Assert
            Assert.Equal(expected, actual);
        }
Пример #6
0
        public void Can_Add_To_BST_Test()
        {
            //arrange
            BinarySearchTree myTree = new BinarySearchTree();

            //act
            myTree.add(4);

            //Assert
            Assert.Equal(4, myTree.Root.Value);
        }