コード例 #1
0
        public void TestInsertNode()
        {
            MacroscopeBinaryTreeGeneric <int> Tree = new MacroscopeBinaryTreeGeneric <int> ();

            const string Name  = "root";
            int          Value = new Random().Next(1, 666);

            Assert.IsNotNull(Tree, "Tree is null");

            MacroscopeBinaryTreeGenericNode <int> Node = Tree.SetRootNode(Name, Value);

            Assert.IsNotNull(Node, "Root node is null");

            Assert.AreEqual(Name, Node.GetNodeName(), "Node name does not match");

            Assert.AreEqual(Value, Node.GetNodeValue(), "Node value does not match");
        }
コード例 #2
0
        public void TestInsertManyNodes()
        {
            MacroscopeBinaryTreeGeneric <int> Tree = new MacroscopeBinaryTreeGeneric <int> ();

            MacroscopeBinaryTreeGenericNode <int> RootNode;
            const string Name  = "root";
            int          Value = new Random().Next(1, 666);

            RootNode = Tree.SetRootNode(Name, Value);

            for (int i = 1; i <= 100; i++)
            {
                MacroscopeBinaryTreeGenericNode <int> ChildNode;
                string ChildName  = i.ToString();
                int    ChildValue = new Random().Next(1, 666);

                ChildNode = Tree.CreateNode(Name: ChildName, Value: Value);

                Assert.IsNotNull(ChildNode, "ChildNode is null");
            }
        }