Beispiel #1
0
        public unsafe void Test_ReadWriteFDA()
        {
            int      nodesCount = 1 + 4 + 4 * 4 + 4 * 4 * 4;
            TestTree tree       = new TestTree(nodesCount);
            int      idx        = 0;

            CreateTestTree(tree, ref idx, 0, 3, 4);
            tree.Version.Major = 4;
            tree.Version.Minor = 2;
            tree.UserData      = 1234567;
            string fileName = Path.Combine(_outDir, "uftree.dat");

            tree.Write(fileName);
            TestTree tree1 = TestTree.ReadFDA <TestTree>(fileName);

            Assert.AreEqual(tree.Version, tree1.Version);
            // Do not check the user data, it is not supported by FDA
            Assert.AreEqual(tree.NodesCount, tree1.NodesCount);
            for (int i = 0; i < tree.NodesCount; ++i)
            {
                Assert.AreEqual(tree.GetDepth(i), tree1.GetDepth(i), i.ToString());
                TestNode n, n1;
                tree.GetNode(i, (byte *)&n);
                tree1.GetNode(i, (byte *)&n1);
                Assert.AreEqual(n.Id, n1.Id, i.ToString());
            }
        }