示例#1
0
        public void EnumerateAllQueues()
        {
            //--------------Get operation--------------
            Test.Assert(CommandAgent.GetAzureStorageQueue(""), Utility.GenComparisonData("EnumerateAllQueues", false));

            // Verification for returned values
            CommandAgent.OutputValidation(StorageAccount.CreateCloudQueueClient().ListQueues());
        }
示例#2
0
        public void GetNonExistingQueue()
        {
            string QUEUE_NAME = Utility.GenNameString("nonexisting");

            // Delete the queue if it exists
            CloudQueue queue = StorageAccount.CreateCloudQueueClient().GetQueueReference(QUEUE_NAME);

            queue.DeleteIfExists();

            //--------------Get operation--------------
            Test.Assert(!CommandAgent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", false));
            // Verification for returned values
            Test.Assert(CommandAgent.Output.Count == 0, "Only 0 row returned : {0}", CommandAgent.Output.Count);
            CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name, QUEUE_NAME);
        }
示例#3
0
        public void QueueWithReadPermission()
        {
            CloudQueue queue = queueUtil.CreateQueue();

            try
            {
                string sastoken = CommandAgent.GetQueueSasFromCmd(queue.Name, string.Empty, "r");
                CommandAgent.SetStorageContextWithSASToken(StorageAccount.Credentials.AccountName, sastoken, StorageEndpoint);

                //list specified queue with properties and meta data
                Test.Assert(CommandAgent.GetAzureStorageQueue(queue.Name), Utility.GenComparisonData("GetAzureStorageQueue", true));
            }
            finally
            {
                queueUtil.RemoveQueue(queue.Name);
            }
        }
示例#4
0
        public void GetMessageCount()
        {
            const int MAX_SIZE   = 32;
            string    QUEUE_NAME = Utility.GenNameString("messagecount-");

            // create queue if not exists
            CloudQueue queue = StorageAccount.CreateCloudQueueClient().GetQueueReference(QUEUE_NAME);

            queue.CreateIfNotExists();
            // insert random count queues
            Random random = new Random();
            int    count  = random.Next(MAX_SIZE) + 1; // count >= 1

            for (int i = 1; i <= count; ++i)
            {
                queue.AddMessage(new CloudQueueMessage("message " + i));
            }

            // generate comparison data
            Collection <Dictionary <string, object> > comp = new Collection <Dictionary <string, object> >();
            var dic = Utility.GenComparisonData(StorageObjectType.Queue, QUEUE_NAME);

            dic["ApproximateMessageCount"] = count;
            comp.Add(dic);

            try
            {
                //--------------Get operation--------------
                Test.Assert(CommandAgent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", true));
                // Verification for returned values
                CommandAgent.OutputValidation(comp);
            }
            finally
            {
                queue.DeleteIfExists();
            }
        }
示例#5
0
        //TODO add test for Get-AzureStorageQueue -Name String.Empty
        public void GetSpecifiedQueueWithMetaData()
        {
            string     queueName = Utility.GenNameString("queue");
            CloudQueue queue     = queueUtil.CreateQueue(queueName);

            try
            {
                //list specified queue with properties and meta data
                Test.Assert(CommandAgent.GetAzureStorageQueue(queueName), Utility.GenComparisonData("GetAzureStorageQueue", true));

                int queueCount = 1;
                Test.Assert(CommandAgent.Output.Count == queueCount, String.Format("Create {0} queues, but retrieved {1} queues", queueCount, CommandAgent.Output.Count));

                // Verification for returned values
                CommandAgent.OutputValidation(new List <CloudQueue>()
                {
                    queue
                });
            }
            finally
            {
                queueUtil.RemoveQueue(queueName);
            }
        }
示例#6
0
        public void QueueListOperations()
        {
            string PREFIX = Utility.GenNameString("uniqueprefix-") + "-";

            string[] QUEUE_NAMES = new string[] { Utility.GenNameString(PREFIX), Utility.GenNameString(PREFIX), Utility.GenNameString(PREFIX) };

            // PART_EXISTING_NAMES differs only the last element with Queue_NAMES
            string[] PARTLY_EXISTING_NAMES = new string[QUEUE_NAMES.Length];
            Array.Copy(QUEUE_NAMES, PARTLY_EXISTING_NAMES, QUEUE_NAMES.Length - 1);
            PARTLY_EXISTING_NAMES[QUEUE_NAMES.Length - 1] = Utility.GenNameString(PREFIX);

            string[] MERGED_NAMES = QUEUE_NAMES.Union(PARTLY_EXISTING_NAMES).ToArray();
            Array.Sort(MERGED_NAMES);

            bool multiOutput = lang == Language.PowerShell;

            // Generate the comparison data
            Collection <Dictionary <string, object> > comp = new Collection <Dictionary <string, object> >();

            foreach (string name in MERGED_NAMES)
            {
                comp.Add(Utility.GenComparisonData(StorageObjectType.Queue, name));
            }

            CloudQueueClient queueClient = StorageAccount.CreateCloudQueueClient();

            // Check if all the above Queues have been removed
            foreach (string name in MERGED_NAMES)
            {
                CloudQueue Queue = queueClient.GetQueueReference(name);
                Queue.DeleteIfExists();
            }

            //--------------1. New operation--------------
            Test.Assert(CommandAgent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", true));
            if (multiOutput)
            {
                // Verification for returned values
                Test.Assert(CommandAgent.Output.Count == 3, "3 row returned : {0}", CommandAgent.Output.Count);
            }

            // Check if all the above queues have been created
            foreach (string name in QUEUE_NAMES)
            {
                CloudQueue queue = queueClient.GetQueueReference(name);
                Test.Assert(queue.Exists(), "queue {0} should exist", name);
            }

            try
            {
                //--------------2. New operation--------------
                if (multiOutput)
                {
                    Test.Assert(!CommandAgent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", false));
                    // Verification for returned values
                    Test.Assert(CommandAgent.Output.Count == 0, "0 row returned : {0}", CommandAgent.Output.Count);

                    int i = 0;
                    foreach (string name in QUEUE_NAMES)
                    {
                        Test.Assert(CommandAgent.ErrorMessages[i].Contains(String.Format("Queue '{0}' already exists.", name)), CommandAgent.ErrorMessages[i]);
                        ++i;
                    }

                    //--------------3. New operation--------------
                    Test.Assert(!CommandAgent.NewAzureStorageQueue(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", false));
                    Test.Assert(CommandAgent.Output.Count == 1, "1 row returned : {0}", CommandAgent.Output.Count);
                }
                else
                {
                    // Queue with the same could be created as long as the metadata is the same.
                    // http://msdn.microsoft.com/en-us/library/azure/dd179342.aspx
                    Test.Assert(CommandAgent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", true));

                    Test.Assert(CommandAgent.NewAzureStorageQueue(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", true));
                    Test.Assert(CommandAgent.Output.Count == 1, "1 row returned : {0}", CommandAgent.Output.Count);
                }

                // Check if all the above queues have been created
                foreach (string name in QUEUE_NAMES)
                {
                    CloudQueue queue = queueClient.GetQueueReference(name);
                    Test.Assert(queue.Exists(), "queue {0} should exist", name);
                }

                //--------------4. Get operation--------------
                if (multiOutput)
                {
                    Test.Assert(CommandAgent.GetAzureStorageQueue("*" + PREFIX + "*"), Utility.GenComparisonData("GetAzureStorageQueue", true));
                    // Verification for returned values
                    CommandAgent.OutputValidation(StorageAccount.CreateCloudQueueClient().ListQueues(PREFIX, QueueListingDetails.All));
                }

                // use Prefix parameter
                Test.Assert(CommandAgent.GetAzureStorageQueueByPrefix(PREFIX), Utility.GenComparisonData("GetAzureStorageQueueByPrefix", true));
                // Verification for returned values
                CommandAgent.OutputValidation(StorageAccount.CreateCloudQueueClient().ListQueues(PREFIX, QueueListingDetails.All));
            }
            finally
            {
                //--------------5. Remove operation--------------
                Test.Assert(CommandAgent.RemoveAzureStorageQueue(MERGED_NAMES), Utility.GenComparisonData("RemoveAzureStorageQueue", true));
                // Check if all the above queues have been removed
                foreach (string name in QUEUE_NAMES)
                {
                    CloudQueue queue = queueClient.GetQueueReference(name);
                    Test.Assert(!queue.Exists(), "queue {0} should not exist", name);
                }
            }
        }