Пример #1
0
        public void DeserializationTransform1()
        {
            using (var ms = new MemoryStream())
            {
                var s = new PODSlimSerializer();

                var originalData = new PODTest_Ver1
                {
                    Name        = "Xerson Person",
                    Description = "Some description",
                    Age         = 25
                };


                s.Serialize(ms, originalData);
                ms.Seek(0, SeekOrigin.Begin);

                var convertedData = s.Deserialize(ms, new PODTestVersionUpgradeStrategy());

                Aver.IsTrue(convertedData is PODTest_Ver2);

                var ver2 = convertedData as PODTest_Ver2;

                Aver.AreEqual(originalData.Name, ver2.Name);
                Aver.AreEqual(originalData.Description, ver2.Description);
                Aver.AreEqual(originalData.Age, ver2.AgeAsOfToday);
                Aver.AreEqual(DateTime.Now.AddYears(-originalData.Age).Year, ver2.DOB.Year);
            }
        }
Пример #2
0
Файл: POD.cs Проект: zhabis/nfx
        public void DeserializationTransform1()
        {
            var originalData = new PODTest_Ver1
            {
                Name        = "Xerson Person",
                Description = "Some description",
                Age         = 25
            };

            var doc = new PortableObjectDocument(originalData);

            var convertedData = doc.ToOriginalObject(new PODTestVersionUpgradeStrategy());

            Aver.IsTrue(convertedData is PODTest_Ver2);

            var ver2 = convertedData as PODTest_Ver2;

            Aver.AreEqual(originalData.Name, ver2.Name);
            Aver.AreEqual(originalData.Description, ver2.Description);
            Aver.AreEqual(originalData.Age, ver2.AgeAsOfToday);
            Aver.AreEqual(DateTime.Now.AddYears(-originalData.Age).Year, ver2.DOB.Year);
        }