/// <summary> /// Functional Cases : for New-AzureStorageQueue /// 1. Create a list of new Queues (Positive 2) /// 2. Create a list of Queues that already exist (Negative 4) /// 3. Create a list of Queues that some of them already exist (Negative 5) /// /// Functional Cases : for Get-AzureStorageQueue /// 4. Get a list of Queues by using wildcards in the name (Positive 2) /// /// Functional Cases : for Remove-AzureStorageQueue /// 5. Remove a list of existing Queues by using pipeline (Positive 3) /// </summary> internal void QueueListOperations(Agent agent) { 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); // 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(agent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", true)); // Verification for returned values Test.Assert(agent.Output.Count == 3, "3 row returned : {0}", agent.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-------------- Test.Assert(!agent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", false)); // Verification for returned values Test.Assert(agent.Output.Count == 0, "0 row returned : {0}", agent.Output.Count); int i = 0; foreach (string name in QUEUE_NAMES) { Test.Assert(agent.ErrorMessages[i].Equals(String.Format("Queue '{0}' already exists.", name)), agent.ErrorMessages[i]); ++i; } //--------------3. New operation-------------- Test.Assert(!agent.NewAzureStorageQueue(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", false)); // Verification for returned values Test.Assert(agent.Output.Count == 1, "1 row returned : {0}", agent.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-------------- Test.Assert(agent.GetAzureStorageQueue("*" + PREFIX + "*"), Utility.GenComparisonData("GetAzureStorageQueue", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudQueueClient().ListQueues(PREFIX, QueueListingDetails.All)); // use Prefix parameter Test.Assert(agent.GetAzureStorageQueueByPrefix(PREFIX), Utility.GenComparisonData("GetAzureStorageQueueByPrefix", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudQueueClient().ListQueues(PREFIX, QueueListingDetails.All)); } finally { //--------------5. Remove operation-------------- Test.Assert(agent.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); } } }
/// <summary> /// Functional Cases : for New-AzureStorageQueue /// 1. Create a list of new Queues (Positive 2) /// 2. Create a list of Queues that already exist (Negative 4) /// 3. Create a list of Queues that some of them already exist (Negative 5) /// /// Functional Cases : for Get-AzureStorageQueue /// 4. Get a list of Queues by using wildcards in the name (Positive 2) /// /// Functional Cases : for Remove-AzureStorageQueue /// 5. Remove a list of existing Queues by using pipeline (Positive 3) /// </summary> internal void QueueListOperations(Agent agent) { 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); // 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(agent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", true)); // Verification for returned values Test.Assert(agent.Output.Count == 3, "3 row returned : {0}", agent.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-------------- Test.Assert(!agent.NewAzureStorageQueue(QUEUE_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", false)); // Verification for returned values Test.Assert(agent.Output.Count == 0, "0 row returned : {0}", agent.Output.Count); int i = 0; foreach (string name in QUEUE_NAMES) { Test.Assert(agent.ErrorMessages[i].Equals(String.Format("Queue '{0}' already exists.", name)), agent.ErrorMessages[i]); ++i; } //--------------3. New operation-------------- Test.Assert(!agent.NewAzureStorageQueue(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageQueue", false)); // Verification for returned values Test.Assert(agent.Output.Count == 1, "1 row returned : {0}", agent.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-------------- Test.Assert(agent.GetAzureStorageQueue("*" + PREFIX + "*"), Utility.GenComparisonData("GetAzureStorageQueue", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudQueueClient().ListQueues(PREFIX, QueueListingDetails.All)); // use Prefix parameter Test.Assert(agent.GetAzureStorageQueueByPrefix(PREFIX), Utility.GenComparisonData("GetAzureStorageQueueByPrefix", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudQueueClient().ListQueues(PREFIX, QueueListingDetails.All)); } finally { //--------------5. Remove operation-------------- Test.Assert(agent.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); } } }