Пример #1
0
        public void ReadOldVersionIntoNewVersion()
        {
            var input = new MyClassVersionOne()
            {
                Id = "42"
            };
            var serializer   = GetSerializer <MyClassVersionOne>();
            var deserializer = GetSerializer <MyClassVersionTwo>();
            var packed       = serializer.Serialize(input);

            var result = deserializer.Deserialize(packed);

            result.Id.Should().Be(42);
        }
Пример #2
0
        public void HandleMultipleVersions()
        {
            var inputOne = new MyClassVersionOne()
            {
                Id = "42"
            };
            var inputTwo = new MyClassVersionTwo()
            {
                Id = 100
            };

            var serializerOne = GetSerializer <MyClassVersionOne>();
            var serializerTwo = GetSerializer <MyClassVersionTwo>();
            var deserializer  = GetSerializer <MyClassVersionThree>();
            var packedOne     = serializerOne.Serialize(inputOne);
            var packedTwo     = serializerTwo.Serialize(inputTwo);

            var resultOne = deserializer.Deserialize(packedOne);
            var resultTwo = deserializer.Deserialize(packedTwo);

            resultOne.UserId.Should().Be("42");
            resultTwo.UserId.Should().Be("100");
        }