Esempio n. 1
0
        public void Should_handle_concrete_message_with_interface_property()
        {
            var messageMapper = new MessageMapper();

            messageMapper.Initialize(new[]
            {
                typeof(MessageWithInterfaceProperty)
            });
            var serializer = new JsonMessageSerializer(messageMapper);

            var message = new MessageWithInterfaceProperty
            {
                InterfaceProperty = new InterfacePropertyImplementation
                {
                    SomeProperty = "test"
                }
            };

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

                stream.Position = 0;

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

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

            var message = new MessageWithInterfaceProperty
            {
                InterfaceProperty = new InterfacePropertyImplementation
                {
                    SomeProperty = "test"
                }
            };

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

                stream.Position = 0;

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

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