Ejemplo n.º 1
0
        public async Task Should_be_able_to_set_message_id_based_on_message_data()
        {
            var message = new Message
            {
                UserProperties = { { "CustomProperty", "CustomValue" } }
            };

            var plugin = new MessageIdPlugin(msg => msg.UserProperties["CustomProperty"].ToString());
            var result = await plugin.BeforeMessageSend(message);

            Assert.Equal("CustomValue", result.MessageId);
        }
Ejemplo n.º 2
0
        public async Task Should_not_assign_message_id_if_it_already_exists()
        {
            var originalMessageId = Guid.NewGuid().ToString();
            var message           = new Message
            {
                MessageId = originalMessageId
            };
            var plugin = new MessageIdPlugin(msg => "this id should never be assigned");

            var result = await plugin.BeforeMessageSend(message);

            Assert.Equal(originalMessageId, result.MessageId);
        }
Ejemplo n.º 3
0
        public async Task Should_assign_message_id()
        {
            var message            = new Message();
            var generatedMessageId = Guid.Empty;
            var plugin             = new MessageIdPlugin(msg =>
            {
                generatedMessageId = Guid.NewGuid();
                return(generatedMessageId.ToString("N"));
            });

            var result = await plugin.BeforeMessageSend(message);

            Assert.Equal(generatedMessageId, Guid.Parse(result.MessageId));
        }