Beispiel #1
0
        public void ClassCDeserializeTest()
        {
            ClassA classA = new ClassA("message from A class", 56.35345f, 65, false, null);
            ClassB classB = new ClassB("message from B class", 57.35345f, 66, true, null);
            ClassC classC = new ClassC("message from C class", 58.35345f, 67, false, null);

            classA.BProperty = classB;
            classB.CProperty = classC;
            classC.AProperty = classA;

            using (FileStream fs = new FileStream("test_output.txt", FileMode.Create))
            {
                IFormatter ownSerializer = new Serializer();
                ownSerializer.Serialize(fs, classC);
            }

            ClassC test;

            using (FileStream fs = new FileStream("test_output.txt", FileMode.Open))
            {
                IFormatter ownSerializer = new Serializer();
                test = ownSerializer.Deserialize(fs) as ClassC;
            }

            Assert.IsTrue(classC.Equals(test));
            Assert.IsTrue(classA.Equals(test.AProperty));
            Assert.IsTrue(classB.Equals(test.AProperty.BProperty));
            File.Delete("test_output.txt");
        }
Beispiel #2
0
        public bool Equals(ISpecElement other)
        {
            var conc = other as Concrete;

            if (conc == null)
            {
                return(false);
            }
            return(ClassB.Equals(conc.ClassB));
        }
Beispiel #3
0
        public void ClassCSerializerTest()
        {
            ClassA classA = new ClassA("message from A class", 56.35345f, 65, false, null);
            ClassB classB = new ClassB("message from B class", 57.35345f, 66, true, null);
            ClassC classC = new ClassC("message from C class", 58.35345f, 67, false, null);

            classA.BProperty = classB;
            classB.CProperty = classC;
            classC.AProperty = classA;

            XmlSerializer f = new XmlSerializer();

            f.Serialize("test_output.xml", classC);

            ClassC test = (ClassC)f.Deserialize("test_output.xml", typeof(ClassC));

            Assert.IsTrue(classC.Equals(test));
            Assert.IsTrue(classA.Equals(test.AProperty));
            Assert.IsTrue(classB.Equals(test.AProperty.BProperty));

            File.Delete("test_output.xml");
        }