public void When_using_the_default_serialization_strategy_messages_are_correctly_round_tripped() { var typeNameSerializer = new TypeNameSerializer(); var serializer = new JsonSerializer( typeNameSerializer ); const string correlationId = "CorrelationId"; var serializationStrategy = new DefaultMessageSerializationStrategy( typeNameSerializer, serializer, () => correlationId ); var messageBody = new MyMessage {Text = "Hello world!"}; var message = new Message<MyMessage>( messageBody ); var serializedMessage = serializationStrategy.SerializeMessage( message ); var deserializedMessage = serializationStrategy.DeserializeMessage( serializedMessage.Properties, serializedMessage.Body ); Assert.That( deserializedMessage.Message.Body.GetType(), Is.EqualTo( message.Body.GetType() ) ); Assert.That( deserializedMessage.Message.Body.Text, Is.EqualTo( message.Body.Text ) ); }
public void When_using_the_default_serialization_strategy_messages_are_correctly_round_tripped_when_null() { var typeNameSerializer = new DefaultTypeNameSerializer(); var serializer = new JsonSerializer(); const string correlationId = "CorrelationId"; var serializationStrategy = new DefaultMessageSerializationStrategy(typeNameSerializer, serializer, new StaticCorrelationIdGenerationStrategy(correlationId)); var message = new Message <MyMessage>(); var serializedMessage = serializationStrategy.SerializeMessage(message); var deserializedMessage = serializationStrategy.DeserializeMessage(serializedMessage.Properties, serializedMessage.Body); Assert.Equal(deserializedMessage.MessageType, message.MessageType); Assert.Null(((Message <MyMessage>)deserializedMessage).Body); }
public void When_using_the_default_serialization_strategy_messages_are_correctly_round_tripped() { var typeNameSerializer = new TypeNameSerializer(); var serializer = new JsonSerializer(typeNameSerializer); const string correlationId = "CorrelationId"; var serializationStrategy = new DefaultMessageSerializationStrategy(typeNameSerializer, serializer, () => correlationId); var messageBody = new MyMessage { Text = "Hello world!" }; var message = new Message <MyMessage>(messageBody); var serializedMessage = serializationStrategy.SerializeMessage(message); var deserializedMessage = serializationStrategy.DeserializeMessage(serializedMessage.Properties, serializedMessage.Body); Assert.That(deserializedMessage.Message.Body.GetType(), Is.EqualTo(message.Body.GetType())); Assert.That(deserializedMessage.Message.Body.Text, Is.EqualTo(message.Body.Text)); }