示例#1
0
        public void SerializeThenDeserialize_NestingPOCO2WithNullValue_HasNullValue()
        {
            // Arrange
            string       actual;
            NestingPOCO2 poco = new NestingPOCO2();

            poco.SetValue(null);
            NestingPOCO2 deserializedPOCO;

            // Act
            deserializedPOCO = SerializeThenDeserialiseNestingPOCO2(poco);
            actual           = deserializedPOCO.GetValue();

            // Assert
            Assert.IsNull(actual);
        }
示例#2
0
        public void SerializeThenDeserialize_NestingPOCO2WithValueOfTesty2_HasValueOfTesty2()
        {
            // Arrange
            string       actual;
            string       expected = "Testy2";
            NestingPOCO2 poco     = new NestingPOCO2();

            poco.SetValue("Testy2");
            NestingPOCO2 deserializedPOCO;

            // Act
            deserializedPOCO = SerializeThenDeserialiseNestingPOCO2(poco);
            actual           = deserializedPOCO.GetValue();

            // Assert
            Assert.AreEqual(expected, actual);
        }
示例#3
0
        private NestingPOCO2 SerializeThenDeserialiseNestingPOCO2(NestingPOCO2 valueToSerialize)
        {
            var applicationContext = _testDIContext.CreateTestApplicationContext();

            System.IO.MemoryStream serializationStream;
            NestingPOCO2           deserializedValue;
            MobileFormatter        formatter = new MobileFormatter(applicationContext);

            // Act
            using (serializationStream = new System.IO.MemoryStream())
            {
                formatter.Serialize(serializationStream, valueToSerialize);
                serializationStream.Seek(0, System.IO.SeekOrigin.Begin);
                deserializedValue = formatter.Deserialize(serializationStream) as NestingPOCO2;
            }

            return(deserializedValue);
        }
示例#4
0
        private NestingPOCO2 SerializeThenDeserialiseNestingPOCO2(NestingPOCO2 valueToSerialize)
        {
            IServiceCollection services = new ServiceCollection();

            services.AddCsla();
            var provider           = services.BuildServiceProvider();
            var ApplicationContext = provider.GetService <ApplicationContext>();

            System.IO.MemoryStream serializationStream;
            NestingPOCO2           deserializedValue;
            MobileFormatter        formatter = new MobileFormatter(ApplicationContext);

            // Act
            using (serializationStream = new System.IO.MemoryStream())
            {
                formatter.Serialize(serializationStream, valueToSerialize);
                serializationStream.Seek(0, System.IO.SeekOrigin.Begin);
                deserializedValue = formatter.Deserialize(serializationStream) as NestingPOCO2;
            }

            return(deserializedValue);
        }