Пример #1
0
        public void EmptyTreeContainsNode()
        {
            // Arrange
            var emptyTree = new ADTAVLTree <int>();
            // Act
            bool contains = emptyTree.Contains(1);

            // Assert
            Assert.AreEqual(false, contains);
        }
Пример #2
0
        public void EmptyTreeAddDeleteContainsNode()
        {
            // Arrange
            var oneElemTree = new ADTAVLTree <int>().Add(1).Delete(1);
            // Act
            bool contains = oneElemTree.Contains(1);

            // Assert
            Assert.AreEqual(false, contains);
        }
Пример #3
0
        public void OneElemTreeContainsNode()
        {
            // Arrange
            var oneElemTree = new ADTAVLTree <int>().Add(1);
            // Act
            bool contains = oneElemTree.Contains(1);

            // Assert
            Assert.AreEqual(true, contains);
        }
Пример #4
0
        public void SameElemTreeContainsNode()
        {
            // Arrange
            var fiveElemTree = new ADTAVLTree <int>()
                               .Add(1).Add(1).Add(1).Add(1).Add(1);
            // Act
            bool contains = fiveElemTree.Contains(1);
            int  height   = fiveElemTree.Height();

            // Assert
            Assert.AreEqual(true, contains);
            Assert.AreEqual(3, height);
        }
Пример #5
0
        public void ThreeElemTreeDeleteNode()
        {
            // Arrange
            var threeElemTree = new ADTAVLTree <int>()
                                .Add(1).Add(1).Add(1);

            threeElemTree.PrettyPrintTree();
            Console.WriteLine();
            threeElemTree.Delete(1);
            threeElemTree.PrettyPrintTree();
            // Act
            bool contains = threeElemTree.Contains(1);
            int  height   = threeElemTree.Height();

            // Assert
            Assert.AreEqual(true, contains);
            Assert.AreEqual(2, height);
        }