Esempio n. 1
0
        public void TestSerialize()
        {
            var x = new CStdImplicitSurrogate();
            var s = new CSurrogate(typeof(CStdImplicitSurrogate));

            var doc = new XmlDocument();

            doc.LoadXml("<_/>");

            var isComplete = s.Serialize(x, doc.DocumentElement, null);

            Assert.AreEqual(true, isComplete, "Expected a complete serialization");
            Assert.AreEqual(ETestStatus.IMPLICIT_SERIALIZER,
                            CStdImplicitSurrogate.STATUS,
                            "The status was not correctly set.");
        }
Esempio n. 2
0
        public void TestImplicitSerializer()
        {
            var x = new CStdImplicitSurrogate
            {
                Name = "Homer",
                Age  = 40
            };

            var s   = new CSerializer();
            var doc = s.Serialize(x);

            Print(doc);
            var elem = doc.DocumentElement;

            Assert.AreEqual(0, elem.ChildNodes.Count, "Node Count");
            Assert.AreEqual(x.Name, XmlExtensions.GetAttributeValue(elem, "NAME"), "Name");
            Assert.AreEqual(x.Age.ToString(), XmlExtensions.GetAttributeValue(elem, "AGE"), "Age");
        }
Esempio n. 3
0
        public void TestDeserialize()
        {
            CStdImplicitSurrogate x = null;
            var s = new CSurrogate(typeof(CStdImplicitSurrogate));

            var doc = new XmlDocument();

            doc.LoadXml("<_ NAME=\"Mike\" AGE='69' />");

            CStdBaseObject.STATUS = ETestStatus.NONE;
            var o          = new CWorkingObject();
            var isComplete = s.Deserialize(o, doc.DocumentElement, null);

            x = (CStdImplicitSurrogate)o.WorkingObject;

            Assert.AreEqual(true, isComplete, "Expected the deserializer to be complete.");
            Assert.AreEqual(ETestStatus.IMPLICIT_DESERIALIZER,
                            CStdImplicitSurrogate.STATUS,
                            "The status was not correctly set.");
        }