Пример #1
0
        public void CtorParameterAndPropertySetterExists()
        {
            var m1 = new ClassWithPropertySetterAndDummyCtor(999)
            {
                MyProperty = 100
            };

            byte[] bin = MessagePackSerializer.Serialize(m1);
            var    m2  = MessagePackSerializer.Deserialize <ClassWithPropertySetterAndDummyCtor>(bin);

            // We do NOT use the property setter since the constructor is expected to set the property.
            Assert.Equal(0, m2.MyProperty);
        }
        public void CtorParameterAndPropertySetterExists()
        {
            var m1 = new ClassWithPropertySetterAndDummyCtor(999)
            {
                MyProperty = 100
            };

            byte[] bin = MessagePackSerializer.Serialize(m1);
            var    m2  = MessagePackSerializer.Deserialize <ClassWithPropertySetterAndDummyCtor>(bin);

            // In this version of the deserializer, we expect the property setter to be invoked
            // and reaffirm the value already passed to the constructor.
            Assert.Equal(m1.MyProperty, m2.MyProperty);
        }