示例#1
0
        /// <summary>
        /// Get the implicit surrogate information for the Type.
        /// </summary>
        private void GetImplicitSurrogate()
        {
            var implicitSurrogate = new CSurrogate(Type);

            if (implicitSurrogate.HasSurrogate) // Only assign to the member field IF the surrogate exists
            {
                ImplicitSurrogate = implicitSurrogate;
            }
        }
示例#2
0
        public void TestNoSurrogate()
        {
            var x = new CNothingImplicitHere();
            var s = new CSurrogate(typeof(CNothingImplicitHere));

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

            Assert.AreEqual(false, isComplete, "Expected the surrogate NOT to complete serialization");

            var newObj = new CWorkingObject();

            isComplete = s.Deserialize(newObj, null, null);

            Assert.AreEqual(false, isComplete, "Expected the surrogate NOT to compelte deserialization");
            Assert.IsNull(newObj.WorkingObject, "Did not expect any object to be returned from Deserialization");
        }
示例#3
0
        public void TestSerializeIncomplete()
        {
            var x = new CIncompleteImplicitSurrogate();
            var s = new CSurrogate(typeof(CIncompleteImplicitSurrogate));

            var doc = new XmlDocument();

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

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

            Assert.AreEqual(false, isComplete, "Expected an incomplete serialization");
            Assert.AreEqual(ETestStatus.IMPLICIT_SERIALIZER_INCOMPLETE,
                            CStdImplicitSurrogate.STATUS,
                            "The status was not correctly set.");
        }
示例#4
0
        public void TestDeserializeIncompleteWithError()
        {
            try
            {
                var s = new CSurrogate(typeof(CIncompleteImplicitSurrogate));

                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);   // Generate the error here.
            }
            catch (TargetInvocationException e)
            {
                throw e.GetBaseException();
            }
        }
示例#5
0
        public void TestDeserializeIncomplete()
        {
            CIncompleteImplicitSurrogate x = null;
            var s = new CSurrogate(typeof(CIncompleteImplicitSurrogate));

            var doc = new XmlDocument();

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

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

            x = (CIncompleteImplicitSurrogate)o.WorkingObject;

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