Esempio n. 1
0
        public void ToServiceBusMessage_Converts_All_Information()
        {
            var queueTMessage = new QueueTMessage
            {
                Id          = "123",
                ContentType = "contentType",
                Properties  = new Dictionary <string, string> {
                    { "prop1", "value1" }
                },
                EncodedBody = new byte[] { 1, 2, 3 },
                Created     = DateTime.UtcNow,
                MessageType = "messageType"
            };

            var sbMessage = queueTMessage.ToServiceBusMessage();

            Assert.Equal(queueTMessage.Id, sbMessage.MessageId);
            Assert.Equal(queueTMessage.ContentType, sbMessage.ContentType);
            Assert.Equal(queueTMessage.EncodedBody, sbMessage.Body);

            Assert.Equal(
                new Dictionary <string, object>
            {
                { "prop1", "value1" },
                { ServiceBusBroker.MessageTypeProperty, queueTMessage.MessageType }
            },
                sbMessage.UserProperties);
        }
Esempio n. 2
0
        public async Task SendAsync(string queueName, QueueTMessage message)
        {
            var queueClient = GetOrCreateQueueClient(queueName);

            var serviceBusMessage = message.ToServiceBusMessage();

            await queueClient.SendAsync(serviceBusMessage);
        }