Exemplo n.º 1
0
        public void TestBinaryTreeRemove_ShouldReturnFalseAndMakeNoChangesToTree_WhenTreeDoesNotContainElementToRemove()
        {
            // arrange
            var binaryTree = new BinaryTree <int> {
                8, 5, 12, 3, 7, 10, 15
            };
            var initialCount = binaryTree.Count;
            // act
            const int remove    = 404;
            var       isRemoved = binaryTree.Remove(remove);

            // assert
            Assert.IsFalse(isRemoved);
            Assert.AreEqual(initialCount, binaryTree.Count);
        }
Exemplo n.º 2
0
        public void TestBinaryTreeRemove_ShouldReturnTrueAndRemoveElementFromTree_WhenTreeContainsElementToRemove()
        {
            // arrange
            var binaryTree = new BinaryTree <int> {
                8, 5, 12, 3, 7, 10, 15
            };
            var initialCount = binaryTree.Count;
            // act
            const int remove    = 10;
            var       isRemoved = binaryTree.Remove(remove);

            // assert
            Assert.IsTrue(isRemoved);
            Assert.IsTrue(binaryTree.Count < initialCount);
        }
Exemplo n.º 3
0
        public void TestBinaryTreeRemove()
        {
            // arrange
            var binaryTree = new BinaryTree <int> {
                8, 5, 12, 3, 7, 10, 15
            };
            var initCnt = binaryTree.Count;
            // act
            const int remove    = 10;
            var       isRemoved = binaryTree.Remove(remove);

            // assert
            Assert.IsTrue(isRemoved);
            Assert.IsTrue(binaryTree.Count < initCnt);
        }