Ejemplo n.º 1
0
        public async Task AQ_Standalone_4()
        {
            TimeSpan visibilityTimeout = TimeSpan.FromSeconds(2);

            queueName = "Test-5-".ToLower() + Guid.NewGuid();
            AzureQueueDataManager manager = await GetTableManager(queueName, visibilityTimeout);

            Assert.Equal(0, await manager.GetApproximateMessageCount());

            var inMessage = "Hello, World";
            await manager.AddQueueMessage(inMessage);

            Assert.Equal(1, await manager.GetApproximateMessageCount());

            QueueMessage outMessage = await manager.GetQueueMessage();

            logger.Info("GetQueueMessage: {0}", PrintQueueMessage(outMessage));
            Assert.Equal(inMessage, outMessage.MessageText);

            await Task.Delay(visibilityTimeout);

            Assert.Equal(1, await manager.GetApproximateMessageCount());

            QueueMessage outMessage2 = await manager.GetQueueMessage();

            Assert.Equal(inMessage, outMessage2.MessageText);

            await manager.DeleteQueueMessage(outMessage2);

            Assert.Equal(0, await manager.GetApproximateMessageCount());
        }
Ejemplo n.º 2
0
        public async Task AQ_Standalone_1()
        {
            queueName = "Test-1-".ToLower() + Guid.NewGuid();
            AzureQueueDataManager manager = await GetTableManager(queueName);

            Assert.AreEqual(0, await manager.GetApproximateMessageCount());

            CloudQueueMessage inMessage = new CloudQueueMessage("Hello, World");
            await manager.AddQueueMessage(inMessage);

            //Nullable<int> count = manager.ApproximateMessageCount;
            Assert.AreEqual(1, await manager.GetApproximateMessageCount());

            CloudQueueMessage outMessage1 = await manager.PeekQueueMessage();

            logger.Info("PeekQueueMessage 1: {0}", AzureStorageUtils.PrintCloudQueueMessage(outMessage1));
            Assert.AreEqual(inMessage.AsString, outMessage1.AsString);

            CloudQueueMessage outMessage2 = await manager.PeekQueueMessage();

            logger.Info("PeekQueueMessage 2: {0}", AzureStorageUtils.PrintCloudQueueMessage(outMessage2));
            Assert.AreEqual(inMessage.AsString, outMessage2.AsString);

            CloudQueueMessage outMessage3 = await manager.GetQueueMessage();

            logger.Info("GetQueueMessage 3: {0}", AzureStorageUtils.PrintCloudQueueMessage(outMessage3));
            Assert.AreEqual(inMessage.AsString, outMessage3.AsString);
            Assert.AreEqual(1, await manager.GetApproximateMessageCount());

            CloudQueueMessage outMessage4 = await manager.GetQueueMessage();

            Assert.IsNull(outMessage4);

            Assert.AreEqual(1, await manager.GetApproximateMessageCount());

            await manager.DeleteQueueMessage(outMessage3);

            Assert.AreEqual(0, await manager.GetApproximateMessageCount());
        }
Ejemplo n.º 3
0
        public async Task AQ_Standalone_1()
        {
            queueName = "Test-1-".ToLower() + Guid.NewGuid();
            AzureQueueDataManager manager = await GetTableManager(queueName);

            Assert.Equal(0, await manager.GetApproximateMessageCount());

            var inMessage = "Hello, World";
            await manager.AddQueueMessage(inMessage);

            //Nullable<int> count = manager.ApproximateMessageCount;
            Assert.Equal(1, await manager.GetApproximateMessageCount());

            var outMessage1 = await manager.PeekQueueMessage();

            logger.Info("PeekQueueMessage 1: {0}", PrintQueueMessage(outMessage1));
            Assert.Equal(inMessage, outMessage1.MessageText);

            var outMessage2 = await manager.PeekQueueMessage();

            logger.Info("PeekQueueMessage 2: {0}", PrintQueueMessage(outMessage2));
            Assert.Equal(inMessage, outMessage2.MessageText);

            QueueMessage outMessage3 = await manager.GetQueueMessage();

            logger.Info("GetQueueMessage 3: {0}", PrintQueueMessage(outMessage3));
            Assert.Equal(inMessage, outMessage3.MessageText);
            Assert.Equal(1, await manager.GetApproximateMessageCount());

            QueueMessage outMessage4 = await manager.GetQueueMessage();

            Assert.Null(outMessage4);

            Assert.Equal(1, await manager.GetApproximateMessageCount());

            await manager.DeleteQueueMessage(outMessage3);

            Assert.Equal(0, await manager.GetApproximateMessageCount());
        }