Skip to content

Commit

Permalink
Read Guid MessageId as string if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Havret committed Jun 12, 2024
1 parent 746f82e commit ff0baab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/ArtemisNetClient/Message/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ private static RestrictedDescribed GetBodySection(object body)

public string MessageId
{
get => Properties.MessageId;
get
{
if (Properties.ObjectMessageId is string stringMessageId)
{
return stringMessageId;
}
return Properties.ObjectMessageId?.ToString();
}
set => Properties.MessageId = value;
}

Expand Down
10 changes: 10 additions & 0 deletions test/ArtemisNetClient.UnitTests/MessageSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -525,5 +525,15 @@ public async Task Should_send_message_without_ContentType()

Assert.Null(messageProcessor.Dequeue(ShortTimeout).ContentType);
}

[Fact]
public void Should_read_guid_MessageId_as_string_if_possible()
{
var messageId = Guid.NewGuid();
var message = new Message("foo");
message.SetMessageId(messageId);

Assert.Equal(messageId.ToString(), message.MessageId);
}
}
}

0 comments on commit ff0baab

Please sign in to comment.