/// <summary> /// Functional Cases : for Get-AzureStorageQueue /// 1. Validate that all the queues can be enumerated (Positive 5) /// </summary> internal void EnumerateAllQueues(Agent agent) { //--------------Get operation-------------- Test.Assert(agent.GetAzureStorageQueue(""), Utility.GenComparisonData("EnumerateAllQueues", false)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudQueueClient().ListQueues()); }
/// <summary> /// Negative Functional Cases : for Get-AzureStorageQueue /// 1. Get a non-existing queue (Negative 1) /// </summary> internal void GetNonExistingQueue(Agent agent) { 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(!agent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", false)); // Verification for returned values Test.Assert(agent.Output.Count == 0, "Only 0 row returned : {0}", agent.Output.Count); Test.Assert(agent.ErrorMessages[0].Equals(String.Format("Can not find queue '{0}'.", QUEUE_NAME)), agent.ErrorMessages[0]); }
internal void StorageQueueTest(Agent agent) { string NEW_QUEUE_NAME = Utility.GenNameString("redmond-"); //--------------New operation-------------- Test.Assert(!agent.NewAzureStorageQueue(NEW_QUEUE_NAME), Utility.GenComparisonData("NewAzureStorageQueue", false)); CheckErrorOutput(agent); //--------------Get operation-------------- Test.Assert(!agent.GetAzureStorageQueue(NEW_QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", false)); CheckErrorOutput(agent); //--------------Remove operation-------------- Test.Assert(!agent.RemoveAzureStorageQueue(NEW_QUEUE_NAME), Utility.GenComparisonData("RemoveAzureStorageQueue", false)); CheckErrorOutput(agent); }
/// <summary> /// Positive Functional Cases : for Get-AzureStorageQueue /// 1. Get the ApproximateMessageCount of the queue (Positive 5) /// </summary> internal void GetMessageCount(Agent agent) { 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 comparsion 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(agent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", true)); // Verification for returned values agent.OutputValidation(comp); } finally { queue.DeleteIfExists(); } }
internal void StorageQueueTest(Agent agent) { string NEW_QUEUE_NAME = Utility.GenNameString("redmond-"); //--------------New operation-------------- Test.Assert(!agent.NewAzureStorageQueue(NEW_QUEUE_NAME), Utility.GenComparisonData("NewAzureStorageQueue", false)); CheckErrorOutput(agent); //--------------Get operation-------------- Test.Assert(!agent.GetAzureStorageQueue(NEW_QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", false)); CheckErrorOutput(agent); //--------------Remove operation-------------- Test.Assert(!agent.RemoveAzureStorageQueue(NEW_QUEUE_NAME), Utility.GenComparisonData("RemoveAzureStorageQueue", false)); CheckErrorOutput(agent); }
/// <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> /// Negative Functional Cases : for Get-AzureStorageQueue /// 1. Get a non-existing queue (Negative 1) /// </summary> internal void GetNonExistingQueue(Agent agent) { 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(!agent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", false)); // Verification for returned values Test.Assert(agent.Output.Count == 0, "Only 0 row returned : {0}", agent.Output.Count); Test.Assert(agent.ErrorMessages[0].Equals(String.Format("Can not find queue '{0}'.", QUEUE_NAME)), agent.ErrorMessages[0]); }
/// <summary> /// Positive Functional Cases : for Get-AzureStorageQueue /// 1. Get the ApproximateMessageCount of the queue (Positive 5) /// </summary> internal void GetMessageCount(Agent agent) { 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 comparsion 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(agent.GetAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("GetAzureStorageQueue", true)); // Verification for returned values agent.OutputValidation(comp); } finally { queue.DeleteIfExists(); } }
/// <summary> /// Functional Cases : for Get-AzureStorageQueue /// 1. Validate that all the queues can be enumerated (Positive 5) /// </summary> internal void EnumerateAllQueues(Agent agent) { //--------------Get operation-------------- Test.Assert(agent.GetAzureStorageQueue(""), Utility.GenComparisonData("EnumerateAllQueues", false)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudQueueClient().ListQueues()); }
/// <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); } } }