示例#1
0
        public void TestSerialization()
        {
            Student peter  = new Student("Peter", TestName.Physics, 7);
            Student john   = new Student("John", TestName.Geography, 7);
            Student frank  = new Student("Frank", TestName.Economics, 8);
            Student robert = new Student("Robert", TestName.Economics, 10);

            Tree <Student> tree = new Tree <Student>();

            tree.Add(peter);
            tree.Add(john);
            tree.Add(frank);
            tree.Add(robert);

            string path = AppDomain.CurrentDomain.BaseDirectory + "/binaryTree.xml";

            TreeSerializer.Serialize(tree, path);

            Tree <Student> treeDeser = TreeSerializer.Deserialize(path);

            Assert.AreEqual(tree.Count, treeDeser.Count);
        }