public async Task GetAllStorageQueues()
        {
            //create two blob containers
            string queueName1           = Recording.GenerateAssetName("testqueue1");
            string queueName2           = Recording.GenerateAssetName("testqueue2");
            StorageQueueResource queue1 = (await _storageQueueCollection.CreateOrUpdateAsync(WaitUntil.Completed, queueName1, new StorageQueueData())).Value;
            StorageQueueResource queue2 = (await _storageQueueCollection.CreateOrUpdateAsync(WaitUntil.Completed, queueName2, new StorageQueueData())).Value;

            //validate if there are two queues
            StorageQueueResource queue3 = null;
            StorageQueueResource queue4 = null;
            int count = 0;

            await foreach (StorageQueueResource queue in _storageQueueCollection.GetAllAsync())
            {
                count++;
                if (queue.Id.Name == queueName1)
                {
                    queue3 = queue;
                }
                if (queue.Id.Name == queueName2)
                {
                    queue4 = queue;
                }
            }
            Assert.AreEqual(count, 2);
            Assert.IsNotNull(queue3);
            Assert.IsNotNull(queue4);
        }
        public async Task CreateDeleteStorageQueue()
        {
            //create storage queue
            string storageQueueName     = Recording.GenerateAssetName("testqueue");
            StorageQueueResource queue1 = (await _storageQueueCollection.CreateOrUpdateAsync(WaitUntil.Completed, storageQueueName, new StorageQueueData())).Value;

            Assert.IsNotNull(queue1);
            Assert.AreEqual(queue1.Id.Name, storageQueueName);

            //validate if successfully created
            StorageQueueResource queue2 = await _storageQueueCollection.GetAsync(storageQueueName);

            AssertStorageQueueEqual(queue1, queue2);
            Assert.IsTrue(await _storageQueueCollection.ExistsAsync(storageQueueName));
            Assert.IsFalse(await _storageQueueCollection.ExistsAsync(storageQueueName + "1"));
            StorageQueueData queueData = queue2.Data;

            Assert.IsEmpty(queueData.Metadata);

            //delete storage queue
            await queue1.DeleteAsync(WaitUntil.Completed);

            //validate if successfully deleted
            Assert.IsFalse(await _storageQueueCollection.ExistsAsync(storageQueueName));
            var exception = Assert.ThrowsAsync <RequestFailedException>(async() => { await _storageQueueCollection.GetAsync(storageQueueName); });

            Assert.AreEqual(404, exception.Status);
        }
        public async Task UpdateStorageQueue()
        {
            //create storage queue
            string storageQueueName     = Recording.GenerateAssetName("testqueue");
            StorageQueueResource queue1 = (await _storageQueueCollection.CreateOrUpdateAsync(WaitUntil.Completed, storageQueueName, new StorageQueueData())).Value;

            Assert.IsNotNull(queue1);
            Assert.AreEqual(queue1.Id.Name, storageQueueName);

            //update queue's meta data
            StorageQueueData queueData = new StorageQueueData();

            queueData.Metadata.Add("key1", "value1");
            queueData.Metadata.Add("key2", "value2");
            StorageQueueResource queue2 = await queue1.UpdateAsync(queueData);

            //validate
            Assert.NotNull(queue2);
            Assert.NotNull(queue2.Data.Metadata);
            Assert.AreEqual(queue2.Data.Metadata["key1"], "value1");
            Assert.AreEqual(queue2.Data.Metadata["key2"], "value2");
        }
 public static void AssertStorageQueueEqual(StorageQueueResource storageQueue1, StorageQueueResource storageQueue2)
 {
     Assert.AreEqual(storageQueue1.Id.Name, storageQueue2.Id.Name);
     Assert.AreEqual(storageQueue1.Id.Location, storageQueue2.Id.Location);
 }