예제 #1
0
        public void Serializ_And_Deserialize_Serializable_Class()
        {
            SerializableA a = new SerializableA();

            a.PublicMember = 20;
            a.IncrementPrivateMember();
            var              i       = a.IncrementPrivateMember();
            Stream           s       = Serialize.SerializeToXmlStream(a);
            NonSerializableA copyOfA = (NonSerializableA)Serialize.DeserializeFromXmlStream(s, typeof(SerializableA));

            Assert.AreEqual(a.PublicMember, copyOfA.PublicMember);
            i = a.IncrementPrivateMember();
            var i_copy = copyOfA.IncrementPrivateMember();

            Assert.AreEqual(i, i_copy);
        }
예제 #2
0
        public void Serailaize_NonSerializable_Class_Test()
        {
            bool             argumentExceptionThrown = false;
            NonSerializableA a = new NonSerializableA();

            a.PublicMember = 10;
            var incrementedPrivateMember = a.IncrementPrivateMember();

            try
            {
                var stream = Serialize.SerializeToXmlStream(a);
            }
            catch (ArgumentException ex)
            {
                argumentExceptionThrown = true;
            }
            Assert.IsTrue(argumentExceptionThrown);
        }