コード例 #1
0
        public async Task UpdateAsync_UpdateDequeuedMessage()
        {
            await using DisposingQueue test = await GetTestQueueAsync();

            var message0 = "foo";
            var message1 = "bar";

            await test.Queue.SendMessageAsync(message0);

            Models.QueueMessage message = (await test.Queue.ReceiveMessagesAsync(1)).Value.First();

            Response <Models.UpdateReceipt> update = await test.Queue.UpdateMessageAsync(
                message.MessageId,
                message.PopReceipt,
                message1);

            Assert.AreNotEqual(update.Value.PopReceipt, message.PopReceipt);
            Assert.AreNotEqual(update.Value.NextVisibleOn, message.NextVisibleOn);

            Models.QueueMessage newMessage = message.Update(update);
            Assert.AreEqual(message.MessageId, newMessage.MessageId);
            Assert.AreEqual(message.MessageText, newMessage.MessageText);
            Assert.AreEqual(message.InsertedOn, newMessage.InsertedOn);
            Assert.AreEqual(message.ExpiresOn, newMessage.ExpiresOn);
            Assert.AreEqual(message.DequeueCount, newMessage.DequeueCount);
            Assert.AreNotEqual(message.PopReceipt, newMessage.PopReceipt);
            Assert.AreNotEqual(message.NextVisibleOn, newMessage.NextVisibleOn);
            Assert.AreEqual(update.Value.PopReceipt, newMessage.PopReceipt);
            Assert.AreEqual(update.Value.NextVisibleOn, newMessage.NextVisibleOn);
        }
コード例 #2
0
        public async Task SendMessage(Models.QueueMessage queueMessage)
        {
            var objToSend = JsonConvert.SerializeObject(queueMessage);
            var message   = new Message(Encoding.UTF8.GetBytes(objToSend));

            // Send the message to the queue.
            await _queueClient.SendAsync(message);
        }