Example #1
0
        public void Test_PreOrderTraversal_Empty_Tree()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //Then
            Assert.Empty(tree.PreOrderTraversal());
        }
Example #2
0
        public void Test_PreOrderTraversal_Tree_Has_1_Node()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //When
            tree.Add(4);
            //Then
            Assert.Equal(new[] { 4 }, tree.PreOrderTraversal());
        }
Example #3
0
        public void Test_PreOrderTraversal_Root_Has_1_Child()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //When
            tree.Add(4);
            tree.Add(2);
            //Then
            Assert.Equal(new[] { 4, 2 }, tree.PreOrderTraversal());
        }
Example #4
0
        public void Test_InsertChild_Should_Add_2_Children_To_Root()
        {
            //Given
            var tree = new BinaryTreeCollection <int>();

            //When
            tree.Add(4);
            tree.Add(2);
            tree.Add(5);
            //Then
            Assert.Equal(new[] { 4, 2, 5 }, tree.PreOrderTraversal());
        }