public void RotateRightRotatesRootNode()
        {
            PointerBackedBinaryTree <int> testTree = new PointerBackedBinaryTree <int>();

            testTree.Root      = new PointerBackedBinaryTreeNode <int>(1, null);
            testTree.Root.Left = new PointerBackedBinaryTreeNode <int>(2, testTree.Root);

            testTree.RotateRight(testTree.Root);

            // Validate the entire tree structure after rotation, including internal pointers.
            Assert.AreEqual(2, testTree.Root.Data);
            Assert.IsNull(testTree.Root.Parent);
            Assert.IsNull(testTree.Root.Left);
            Assert.AreEqual(1, testTree.Root.Right.Data);
            Assert.AreEqual(testTree.Root, testTree.Root.Right.Parent);
            Assert.IsNull(testTree.Root.Right.Right);
            Assert.IsNull(testTree.Root.Right.Left);
        }
        public void RotateRightRotatesNode()
        {
            PointerBackedBinaryTree <int> testTree = new PointerBackedBinaryTree <int>();

            testTree.Root                   = new PointerBackedBinaryTreeNode <int>(1, null);
            testTree.Root.Right             = new PointerBackedBinaryTreeNode <int>(2, testTree.Root);
            testTree.Root.Right.Left        = new PointerBackedBinaryTreeNode <int>(3, testTree.Root.Right);
            testTree.Root.Right.Right       = new PointerBackedBinaryTreeNode <int>(4, testTree.Root.Right);
            testTree.Root.Right.Right.Left  = new PointerBackedBinaryTreeNode <int>(5, testTree.Root.Right.Right);
            testTree.Root.Right.Right.Right = new PointerBackedBinaryTreeNode <int>(6, testTree.Root.Right.Right);

            testTree.RotateRight(testTree.Root.Right);

            // Validate the tree structure
            Assert.AreEqual(1, testTree.Root.Data);
            Assert.AreEqual(3, testTree.Root.Right.Data);
            Assert.AreEqual(2, testTree.Root.Right.Right.Data);
            Assert.AreEqual(4, testTree.Root.Right.Right.Right.Data);
            Assert.AreEqual(5, testTree.Root.Right.Right.Right.Left.Data);
            Assert.AreEqual(6, testTree.Root.Right.Right.Right.Right.Data);
        }