public void Delete_SeveralElementsTree_ShouldWorkCorrectly()
        {
            var bst = new BinarySearchTree <int>();

            bst.Insert(20);
            bst.Insert(10);
            bst.Insert(5);
            bst.Insert(15);
            bst.Insert(17);
            bst.Insert(30);
            bst.Insert(25);
            bst.Insert(35);

            bst.Delete(10);
            bst.Delete(30);
            bst.Delete(80);

            var nodes = new List <int>();

            bst.EachInOrder(nodes.Add);
            var expectedNodes = new int[] { 5, 15, 17, 20, 25, 35 };

            CollectionAssert.AreEqual(expectedNodes, nodes);
            Assert.AreEqual(expectedNodes.Length, bst.Count());
        }
        public void Delete_OneElementTree_ShouldMakeTreeEmpty()
        {
            var bst = new BinarySearchTree <int>();

            bst.Insert(5);

            bst.Delete(5);

            var nodes = new List <int>();

            bst.EachInOrder(nodes.Add);
            int[] expectedNodes = new int[] { };
            CollectionAssert.AreEqual(expectedNodes, nodes);
            Assert.AreEqual(expectedNodes.Length, bst.Count());
        }
        public void Insert_Single_TraverseInOrder()
        {
            var bst = new BinarySearchTree <int>();

            bst.Insert(1);

            var nodes = new List <int>();

            bst.EachInOrder(nodes.Add);

            var expectedNodes = new int[] { 1 };

            CollectionAssert.AreEqual(expectedNodes, nodes);
            Assert.AreEqual(expectedNodes.Length, bst.Count());
        }