Example #1
0
        public void TestGetDiameterOfBinaryTree1()
        {
            // Arrange

            // Act
            BinaryTreeOperations treeOperations = new BinaryTreeOperations();
            var result = treeOperations.GetDiameterOfBinaryTree(root);

            // Assert
            Assert.AreEqual(4, result, "Wrong Value");
        }
Example #2
0
        public void TestGetDiameterOfBinaryTree2()
        {
            // Arrange
            var root = new TreeNode(1);

            root.Left       = new TreeNode(2);
            root.Left.Right = new TreeNode(5);
            root.Right      = new TreeNode(3);

            // Act
            BinaryTreeOperations treeOperations = new BinaryTreeOperations();
            var result = treeOperations.GetDiameterOfBinaryTree(root);

            // Assert
            Assert.AreEqual(3, result, "Wrong Value");
        }