Пример #1
0
        /// <summary>
        /// Negative Functional Cases : for Remove-AzureStorageQueue
        /// 1. Remove the queue without by force (Negative 3)
        /// </summary>
        internal void RemoveQueueWithoutForce(Agent agent)
        {
            string QUEUE_NAME = Utility.GenNameString("withoutforce-");

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

            queue.CreateIfNotExists();

            try
            {
                //--------------Remove operation--------------
                Test.Assert(!agent.RemoveAzureStorageQueue(QUEUE_NAME, false), Utility.GenComparisonData("RemoveAzureStorageQueue", false));
                // Verification for returned values
                Test.Assert(agent.Output.Count == 0, "Only 0 row returned : {0}", agent.Output.Count);
                Test.Assert(agent.ErrorMessages[0].StartsWith("A command that prompts the user failed because"), agent.ErrorMessages[0]);
            }
            finally
            {
                queue.DeleteIfExists();
            }
        }
Пример #2
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);
        }
Пример #3
0
        /// <summary>
        /// Negative Functional Cases : for Remove-AzureStorageQueue 
        /// 1. Remove the queue without by force (Negative 3)
        /// </summary>
        internal void RemoveQueueWithoutForce(Agent agent)
        {
            string QUEUE_NAME = Utility.GenNameString("withoutforce-");

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

            try
            {
                //--------------Remove operation--------------
                Test.Assert(!agent.RemoveAzureStorageQueue(QUEUE_NAME, false), Utility.GenComparisonData("RemoveAzureStorageQueue", false));
                // Verification for returned values
                Test.Assert(agent.Output.Count == 0, "Only 0 row returned : {0}", agent.Output.Count);
                Test.Assert(agent.ErrorMessages[0].StartsWith("A command that prompts the user failed because"), agent.ErrorMessages[0]);
            }
            finally
            {
                queue.DeleteIfExists();
            }
        }
Пример #4
0
        /// <summary>
        /// Negative Functional Cases : for Remove-AzureStorageQueue 
        /// 1. Remove a non-existing queue (Negative 2)
        /// </summary>
        internal void RemoveNonExistingQueue(Agent agent)
        {
            string QUEUE_NAME = Utility.GenNameString("nonexisting");

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

            //--------------Remove operation--------------
            Test.Assert(!agent.RemoveAzureStorageQueue(QUEUE_NAME), Utility.GenComparisonData("RemoveAzureStorageQueue", 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]);
        }
Пример #5
0
        /// <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);
                }
            }
        }
Пример #6
0
        /// <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);
                }
            }
        }