コード例 #1
0
        public void IsRightChild_Success()
        {
            var A = new MockBinaryTreeNode <int, string>(5, "A");
            var B = new MockBinaryTreeNode <int, string>(10, "B");
            var C = new MockBinaryTreeNode <int, string>(20, "C");

            A.Parent     = null;
            A.LeftChild  = null;
            A.RightChild = B;

            B.Parent     = A;
            B.LeftChild  = null;
            B.RightChild = C;

            C.Parent     = B;
            C.LeftChild  = null;
            C.RightChild = null;

            Assert.IsTrue(B.IsRightChild());
            Assert.IsTrue(C.IsRightChild());
        }
コード例 #2
0
        public void IsRightChild_Failure()
        {
            var A = new MockBinaryTreeNode <int, string>(10, "A");
            var B = new MockBinaryTreeNode <int, string>(5, "B");
            var C = new MockBinaryTreeNode <int, string>(2, "C");

            A.Parent     = null;
            A.LeftChild  = B;
            A.RightChild = null;

            B.Parent     = A;
            B.LeftChild  = C;
            B.RightChild = null;

            C.Parent     = B;
            C.LeftChild  = null;
            C.RightChild = null;

            Assert.IsFalse(A.IsRightChild());
            Assert.IsFalse(B.IsRightChild());
            Assert.IsFalse(C.IsRightChild());
        }