public void GetMessageType_returns_message_type_for_a_versioned_message() { var typeNameSerialiser = new DefaultTypeNameSerializer(); var property = MessageTypeProperty.CreateForMessageType(typeof(MyMessageV2), typeNameSerialiser); var messageType = property.GetMessageType(); Assert.Equal(typeof(MyMessageV2), messageType); }
public void GetMessageType_returns_message_type_for_a_versioned_message() { var typeNameSerialiser = new TypeNameSerializer(); var property = MessageTypeProperty.CreateForMessageType(typeof(MyMessageV2), typeNameSerialiser); var messageType = property.GetMessageType(); Assert.That(messageType.Type, Is.EqualTo(typeof(MyMessageV2))); }
public void AppendTo_sets_message_type_and_alternatives_for_a_versioned_message() { var typeNameSerialiser = new DefaultTypeNameSerializer(); var property = MessageTypeProperty.CreateForMessageType(typeof(MyMessageV2), typeNameSerialiser); var properties = new MessageProperties(); property.AppendTo(properties); Assert.Equal(properties.Type, typeNameSerialiser.Serialize(typeof(MyMessageV2))); Assert.Equal(properties.Headers[AlternativeMessageTypesHeaderKey], typeNameSerialiser.Serialize(typeof(MyMessage))); }
public void AppendTo_sets_message_type_and_no_alternatives_for_an_unversioned_message() { var typeNameSerialiser = new TypeNameSerializer(); var property = MessageTypeProperty.CreateForMessageType(typeof(MyMessage), typeNameSerialiser); var properties = new MessageProperties(); property.AppendTo(properties); Assert.That(properties.Type, Is.EqualTo(typeNameSerialiser.Serialize(typeof(MyMessage)))); Assert.That(properties.Headers.ContainsKey(AlternativeMessageTypesHeaderKey), Is.False); }
public SerializedMessage SerializeMessage(IMessage message) { var messageBody = serializer.MessageToBytes(message.MessageType, message.GetBody()); var messageTypeProperties = MessageTypeProperty.CreateForMessageType(message.MessageType, typeNameSerializer); var messageProperties = message.Properties; messageTypeProperties.AppendTo(messageProperties); if (string.IsNullOrEmpty(messageProperties.CorrelationId)) { messageProperties.CorrelationId = correlationIdGenerator.GetCorrelationId(); } return new SerializedMessage(messageProperties, messageBody); }