public void Test_BST_DeleteLeftNodeWithChildren()
        {
            BinaryTreeNode <int> root = new BinaryTreeNode <int>(10);

            root.Insert(9);

            root.Insert(8);

            root.Insert(11);

            root.Insert(5);

            root.Insert(7);

            root.Insert(23);

            root.Insert(4);

            var node = root.Search(9);

            root.Delete(node);

            Assert.AreEqual(8, root.Left.Value);
            Assert.AreEqual(7, root.Left.Left.Value);
            Assert.AreEqual(5, root.Left.Left.Left.Value);
            Assert.AreEqual(4, root.Left.Left.Left.Left.Value);
            Assert.IsNull(root.Left.Left.Left.Right);
        }
        private void DeleteBinarySearchTree(BinaryTreeNode <int> root, int value, IList <int> expected)
        {
            root.Delete(value);

            expected.Remove(value);

            var idx = 0;

            root.InOrderTraversal((v) => { Assert.AreEqual <int>(expected[idx], v); idx++; });
        }
        public void Test_BST_DeleteRightNodeWithChildren()
        {
            BinaryTreeNode <int> root = new BinaryTreeNode <int>(10);

            /*
             *
             *                10
             *              /   \
             *             9     11
             *            /       \
             *           8         23
             *          /          / \
             *         5          12  36
             \          \
             \           7          14
             */

            root.Insert(9);

            root.Insert(8);

            root.Insert(11);

            root.Insert(5);

            root.Insert(7);

            root.Insert(23);

            root.Insert(4);

            root.Insert(12);

            root.Insert(14);

            root.Insert(36);

            var node = root.Search(23);

            root.Delete(node);

            Assert.AreEqual(14, root.Right.Right.Value);
            Assert.AreEqual(12, root.Right.Right.Left.Value);
            Assert.AreEqual(36, root.Right.Right.Right.Value);
            Assert.IsNull(root.Right.Right.Left.Right);
        }