Exemple #1
0
        public void TestTreeEqual()
        {
            // tree 1
            ItemInfoTree tree    = new ItemInfoTree();
            ItemInfoTree subtree = new ItemInfoTree();

            subtree.WriteDouble("DOUBLE", 2.0);

            tree.WriteInt("INT", 1);
            tree.WriteDouble("DOUBLE", 1.0);
            tree.WriteIntArray("INTARRAY", new int[] { 1, 2, 3 });
            tree.WriteString("STRING", "XX");
            tree.WriteTree("TREE", subtree);

            // tree 2
            ItemInfoTree tree2    = new ItemInfoTree();
            ItemInfoTree subtree2 = new ItemInfoTree();

            subtree2.WriteDouble("DOUBLE", 2.0);

            tree2.WriteInt("INT", 1);
            tree2.WriteDouble("DOUBLE", 1.0);
            tree2.WriteIntArray("INTARRAY", new int[] { 1, 2, 3 });
            tree2.WriteString("STRING", "XX");
            tree2.WriteTree("TREE", subtree2);

            Assert.IsTrue(tree.Equals(tree2));

            tree2.WriteIntArray("INTARRAY", new int[] { 1, 2, 2 });
            Assert.IsFalse(tree.Equals(tree2));

            tree2.WriteIntArray("INTARRAY", new int[] { 1, 2, 3 });
            Assert.IsTrue(tree.Equals(tree2));

            subtree2.WriteInt("stuff", 2);
            Assert.IsFalse(tree.Equals(tree2));
        }
Exemple #2
0
        public void TestClone()
        {
            ItemInfoTree tree    = new ItemInfoTree();
            ItemInfoTree subtree = new ItemInfoTree();

            subtree.WriteDouble("DOUBLE", 2.0);

            tree.WriteInt("INT", 1);
            tree.WriteDouble("DOUBLE", 1.0);
            tree.WriteIntArray("INTARRAY", new int[] { 1, 2, 3 });
            tree.WriteString("STRING", "XX");
            tree.WriteTree("TREE", subtree);

            ItemInfoTree tree2 = new ItemInfoTree(tree);

            Assert.IsTrue(tree.Equals(tree2));
            Assert.AreNotSame(tree.ReadIntArray("INTARRAY"), tree2.ReadIntArray("INTARRAY"));
            Assert.AreNotSame(tree.ReadTree("TREE"), tree2.ReadTree("TREE"));
        }