Пример #1
0
        public void Can_Deserialize_Mixture_Of_Empty_Elements_With_Attributes_And_Populated_Elements()
        {
            string          doc    = CreateXmlWithAttributesAndNullValuesAndPopulatedValues();
            XmlDeserializer xml    = new XmlDeserializer();
            NullableValues  output = xml.Deserialize <NullableValues>(new RestResponse {
                Content = doc
            });

            Assert.Null(output.Id);
            Assert.Null(output.StartDate);
            Assert.AreEqual(new Guid(GUID_STRING), output.UniqueId);
        }
Пример #2
0
        public void Can_Deserialize_Empty_Elements_to_Nullable_Values()
        {
            string         doc    = CreateJsonWithEmptyValues();
            JsonSerializer json   = new JsonSerializer();
            NullableValues output = json.Deserialize <NullableValues>(new RestResponse {
                Content = doc
            });

            Assert.Null(output.Id);
            Assert.Null(output.StartDate);
            Assert.Null(output.UniqueId);
        }
Пример #3
0
        public void Can_Deserialize_Empty_Elements_With_Attributes_to_Nullable_Values()
        {
            string          doc    = CreateXmlWithAttributesAndNullValues();
            XmlDeserializer xml    = new XmlDeserializer();
            NullableValues  output = xml.Deserialize <NullableValues>(new RestResponse {
                Content = doc
            });

            Assert.Null(output.Id);
            Assert.Null(output.StartDate);
            Assert.Null(output.UniqueId);
        }
Пример #4
0
        public void Can_Deserialize_Elements_to_Nullable_Values()
        {
            string           doc    = CreateJsonWithoutEmptyValues();
            JsonDeserializer json   = new JsonDeserializer();
            NullableValues   output = json.Deserialize <NullableValues>(new RestResponse {
                Content = doc
            });

            Assert.NotNull(output.Id);
            Assert.NotNull(output.StartDate);
            Assert.NotNull(output.UniqueId);

            Assert.AreEqual(123, output.Id);
            Assert.NotNull(output.StartDate);
            Assert.AreEqual(
                new DateTime(2010, 2, 21, 9, 35, 00, DateTimeKind.Utc),
                output.StartDate.Value);
            Assert.AreEqual(new Guid(GUID_STRING), output.UniqueId);
        }
Пример #5
0
        public void Can_Deserialize_Elements_to_Nullable_Values()
        {
            CultureInfo     culture = CultureInfo.InvariantCulture;
            string          doc     = CreateXmlWithoutEmptyValues(culture);
            XmlDeserializer xml     = new XmlDeserializer
            {
                Culture = culture
            };
            NullableValues output = xml.Deserialize <NullableValues>(new RestResponse {
                Content = doc
            });

            Assert.NotNull(output.Id);
            Assert.NotNull(output.StartDate);
            Assert.NotNull(output.UniqueId);
            Assert.AreEqual(123, output.Id);
            Assert.AreEqual(new DateTime(2010, 2, 21, 9, 35, 00), output.StartDate);
            Assert.AreEqual(new Guid(GUID_STRING), output.UniqueId);
        }