コード例 #1
0
        public void TestCreateTreeWithIntegerRoot()
        {
            ITree <int> tree = new Tree.Tree <int>(5);

            Assert.AreEqual(5, tree.Root.Value);
            Assert.IsNotNull(tree.Root);
        }
コード例 #2
0
        public void TestCreateTreeWithRootByReference()
        {
            ITreeNode <int> node = new TreeNode <int>(5);

            ITree <int> tree = new Tree.Tree <int>(node);

            Assert.AreSame(node, tree.Root);
        }
コード例 #3
0
        public void TestCreateTreeWithChildrenNodes()
        {
            var nodes = new List <ITreeNode <int> >();

            for (int i = 0; i < 10; i++)
            {
                nodes.Add(new TreeNode <int>(i * 5));
            }

            ITree <int> tree = new Tree.Tree <int>(0);

            tree.Root.Children = nodes;
            Assert.AreEqual(10, tree.Root.Children.Count());
        }
コード例 #4
0
        public void TestCheckTreeChildrenNodeValues()
        {
            var nodes = new List <ITreeNode <int> >();

            for (int i = 0; i < 10; i++)
            {
                nodes.Add(new TreeNode <int>(i * 5));
            }

            ITree <int> tree = new Tree.Tree <int>(0);

            tree.Root.Children = nodes;
            Assert.AreEqual(0, tree.Root.Children.First().Value);         // first
            Assert.AreEqual(5, tree.Root.Children.Skip(1).First().Value); // second
        }
コード例 #5
0
        public void TestCreateTreeWithEmptyRoot()
        {
            ITree <int> tree = new Tree.Tree <int>();

            Assert.IsNull(tree.Root);
        }