Ejemplo n.º 1
0
        public void Should_handle_concrete_message_with_invalid_interface_property()
        {
            var messageMapper = new MessageMapper();

            messageMapper.Initialize(new[]
            {
                typeof(MessageWithInvalidInterfaceProperty)
            });

            var serializer = new JsonMessageSerializer(messageMapper);

            var message = new MessageWithInvalidInterfaceProperty
            {
                InterfaceProperty = new InvalidInterfacePropertyImplementation
                {
                    SomeProperty = "test"
                }
            };

            using (var stream = new MemoryStream())
            {
                serializer.Serialize(message, stream);

                stream.Position = 0;

                var result = (MessageWithInvalidInterfaceProperty)serializer.Deserialize(stream, new[]
                {
                    typeof(MessageWithInvalidInterfaceProperty)
                })[0];

                Assert.AreEqual(message.InterfaceProperty.SomeProperty, result.InterfaceProperty.SomeProperty);
            }
        }
        public void Should_handle_concrete_message_with_invalid_interface_property()
        {
            var messageMapper = new MessageMapper();
            messageMapper.Initialize(new[]
            {
                typeof(MessageWithInvalidInterfaceProperty)
            });

            var serializer = new JsonMessageSerializer(messageMapper);

            var message = new MessageWithInvalidInterfaceProperty
            {
                InterfaceProperty = new InvalidInterfacePropertyImplementation
                {
                    SomeProperty = "test"
                }
            };

            using (var stream = new MemoryStream())
            {
                serializer.Serialize(message, stream);

                stream.Position = 0;

                var result = (MessageWithInvalidInterfaceProperty) serializer.Deserialize(stream, new[]
                {
                    typeof(MessageWithInvalidInterfaceProperty)
                })[0];

                Assert.AreEqual(message.InterfaceProperty.SomeProperty, result.InterfaceProperty.SomeProperty);
            }
        }