Exemplo n.º 1
0
        public void TestSerializeSubClassWithOverriddenDefaultValues()
        {
            var settings = new SerializerSettings();

            settings.RegisterAssembly(typeof(SerializationSubClassTests).Assembly);
            var serializer = new Serializer(settings);

            var value    = new TestSubClass1();
            var text     = serializer.Serialize(value);
            var newValue = serializer.Deserialize <TestSubClass1>(text);

            Assert.Equal(value.IsSelected, newValue.IsSelected);
            Assert.Equal(value.Size.Width, newValue.Size.Width);
            Assert.Equal(value.Size.Height, newValue.Size.Height);
        }
Exemplo n.º 2
0
        public void TestSerializeSubClassWithValuesSameAsBaseClassValues()
        {
            var settings = new SerializerSettings();

            settings.RegisterAssembly(typeof(SerializationSubClassTests).Assembly);
            var serializer = new Serializer(settings);

            var value = new TestSubClass1();

            value.IsSelected = false;
            value.Size       = new Size {
                Width = 10, Height = 10
            };
            var text     = serializer.Serialize(value);
            var newValue = serializer.Deserialize <TestSubClass1>(text);

            Assert.Equal(value.IsSelected, newValue.IsSelected);
            Assert.Equal(value.Size.Width, newValue.Size.Width);
            Assert.Equal(value.Size.Height, newValue.Size.Height);
        }