Ejemplo n.º 1
0
        public void ClassPrimitiveTypesNullableSetNull()
        {
            var obj = new TestClassPrimitiveTypesNullable();

            obj.InitNull();

            CheckSerializationAndDeserialization("ExtendedXmlSerializerTest.Resources.TestClassPrimitiveTypesNullableSetNull.xml", obj);
            CheckCompatibilityWithDefaultSerializator(obj);
        }
        public void VerifyAutoFormattingForNullableWithValue()
        {
            var support  = new SerializationSupport(new ConfigurationContainer().UseAutoFormatting().Create());
            var instance = new TestClassPrimitiveTypesNullable();

            instance.Init();
            var data     = support.Serialize(instance);
            var expected = @"<?xml version=""1.0"" encoding=""utf-8""?><TestClassPrimitiveTypesNullable PropString=""TestString"" PropInt=""-1"" PropuInt=""2234"" PropDecimal=""3.346"" PropFloat=""7.4432"" PropDouble=""3.4234"" PropEnum=""EnumValue1"" PropLong=""234234142"" PropUlong=""2345352534"" PropShort=""23"" PropUshort=""2344"" PropDateTime=""2014-01-23T00:00:00"" PropByte=""23"" PropSbyte=""33"" PropChar=""g"" xmlns=""clr-namespace:ExtendedXmlSerializer.Tests.TestObject;assembly=ExtendedXmlSerializer.Tests"" />";

            data.ShouldBeEquivalentTo(expected);
        }
        public void VerifyAutoFormattingForNullableWithNull()
        {
            var support  = new SerializationSupport(new ConfigurationContainer().UseAutoFormatting().Create());
            var instance = new TestClassPrimitiveTypesNullable();

            instance.InitNull();
            var data = support.Serialize(instance);

            Assert.Equal(
                @"<?xml version=""1.0"" encoding=""utf-8""?><TestClassPrimitiveTypesNullable xmlns=""clr-namespace:ExtendedXmlSerializer.Tests.TestObject;assembly=ExtendedXmlSerializer.Tests"" />",
                data
                );
        }