示例#1
0
        public void LeftSubTree_NonEmpty_IsEqualToConstructionArgument()
        {
            var subtree = BinaryTree.Create(0);
            var tree    = BinaryTree.Create(subtree, BinaryTree <int> .Empty, 0);

            Assert.That(tree.LeftSubTree, Is.EqualTo(subtree));
        }
示例#2
0
        public void Create_SubTreesAreEmpty()
        {
            var tree = BinaryTree.Create(0);

            Assert.That(tree.LeftSubTree.IsEmpty, Is.True);
            Assert.That(tree.RightSubTree.IsEmpty, Is.True);
        }
示例#3
0
        public void ForEachPostOrder_SmallTree_ActionIsCalledWithElementsInOrder()
        {
            var tree = BinaryTree.Create(BinaryTree.Create(2), BinaryTree.Create(3), 1);
            var list = new List <int>();

            tree.ForEachPostOrder(list.Add);
            Assert.That(list, Is.EqualTo(new[] { 2, 3, 1 }));
        }
示例#4
0
        public void LeftSubTree_EmptySubTree_IsEmpty()
        {
            var tree = BinaryTree.Create(0);

            Assert.That(tree.LeftSubTree.IsEmpty, Is.True);
        }
示例#5
0
        public void Any_NonEmpty_IsTrue()
        {
            var tree = BinaryTree.Create(0);

            Assert.That(tree.Any, Is.True);
        }
示例#6
0
        public void IsEmpty_NonEmpty_IsFalse()
        {
            var tree = BinaryTree.Create(0);

            Assert.That(tree.IsEmpty, Is.False);
        }
示例#7
0
        public void Create_RootValueContainsElement()
        {
            var tree = BinaryTree.Create(42);

            Assert.That(tree.RootValue, Is.EqualTo(42));
        }
示例#8
0
        public void RootValue_NonEmpty_IsRootElement()
        {
            var tree = BinaryTree.Create(42);

            Assert.That(tree.RootValue, Is.EqualTo(42));
        }