コード例 #1
0
        public void UpdateMessage_NonExistentMessage_ThrowsException()
        {
            IQueueServiceClient client = new QueueServiceClient(_accountSettings);
            var queueName = GenerateSampleQueueName();
            _util.CreateQueue(queueName);

            client.UpdateMessage(queueName, "123-abc", FakePopReceipt, 0);

            // expects exception
        }
コード例 #2
0
        public void UpdateMessage_InvalidXMLMessageTextCharacters_DoesNotThrowException()
        {
            const string rawFirstText = "<QueueMessage><MessageText>Test</MessageText></QueueMessage>";
            const string rawSecondText = "{\"KeyValueLogPayload\": {\"UserIP\": \"::1\",\"URL\": \"http://fakeurl/foo?bar=baz&baz=bar\"}}";
            IQueueServiceClient client = new QueueServiceClient(_accountSettings);
            var queueName = GenerateSampleQueueName();
            _util.CreateQueue(queueName);
            _util.AddItemsToQueue(queueName, new List<string>() { rawFirstText });
            var itemFromQueue = _util.GetItemFromQueue(queueName, 1);

            Assert.DoesNotThrow(() =>
            {
                client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0, rawSecondText);
            });
        }
コード例 #3
0
        public void UpdateMessage_DifferentMessageText_ChangesMessageText()
        {
            const string rawFirstText = "1";
            const string rawSecondText = "2";
            var firstText = Convert.ToBase64String(Encoding.UTF8.GetBytes(rawFirstText));
            var secondText = Convert.ToBase64String(Encoding.UTF8.GetBytes(rawSecondText));
            IQueueServiceClient client = new QueueServiceClient(_accountSettings);
            var queueName = GenerateSampleQueueName();
            _util.CreateQueue(queueName);
            _util.AddItemsToQueue(queueName, new List<string>() { firstText });
            var itemFromQueue = _util.GetItemFromQueue(queueName, 1);

            client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0, secondText);

            var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
            Assert.AreEqual(rawSecondText, itemFromQueueAgain.AsString);
        }
コード例 #4
0
        public void UpdateMessage_ExtendVisibility_ExtendsMessageVisibilityInTheQueue()
        {
            IQueueServiceClient client = new QueueServiceClient(_accountSettings);
            var queueName = GenerateSampleQueueName();
            _util.CreateQueue(queueName);
            _util.AddItemsToQueue(queueName, new List<string>() { "1" });
            var itemFromQueue = _util.GetItemFromQueue(queueName, 1);

            var response = client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 30);

            Assert.IsNotNullOrEmpty(response.PopReceipt);
            Thread.Sleep(2000); // longer than the original visibility timeout
            var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
            Assert.IsNull(itemFromQueueAgain);
        }
コード例 #5
0
        public void UpdateMessage_UpdateContent_UpdatesContentOfMessageInQueue()
        {
            IQueueServiceClient client = new QueueServiceClient(_accountSettings);
            var queueName = GenerateSampleQueueName();
            _util.CreateQueue(queueName);
            _util.AddItemsToQueue(queueName, new List<string>() { "1" });
            var itemFromQueue = _util.GetItemFromQueue(queueName);
            var newString = Convert.ToBase64String(Encoding.ASCII.GetBytes("2"));   // the official SDK base 64's the values automatically

            client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0, newString);

            var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
            Assert.IsNotNull(itemFromQueueAgain);
            Assert.AreEqual(itemFromQueue.Id, itemFromQueueAgain.Id);
            Assert.AreEqual("1", itemFromQueue.AsString);
            Assert.AreEqual("2", itemFromQueueAgain.AsString);
        }
コード例 #6
0
        public void UpdateMessage_ClearVisibility_AllowsMessageToBeRetrievedAgain()
        {
            IQueueServiceClient client = new QueueServiceClient(_accountSettings);
            var queueName = GenerateSampleQueueName();
            _util.CreateQueue(queueName);
            _util.AddItemsToQueue(queueName, new List<string>() { "1" });
            var itemFromQueue = _util.GetItemFromQueue(queueName);

            client.UpdateMessage(queueName, itemFromQueue.Id, itemFromQueue.PopReceipt, 0);

            var itemFromQueueAgain = _util.GetItemFromQueue(queueName);
            Assert.IsNotNull(itemFromQueueAgain);
            Assert.AreEqual(itemFromQueue.Id, itemFromQueueAgain.Id);
        }