/// <summary> /// Negative Functional Cases : for New-AzureStorageTable /// 1. Create a new table with an invalid table name (Negative 1) /// </summary> internal void CreateInvalidTable(Agent agent) { string tableName = Utility.GenNameString("abc_"); //--------------New operation-------------- Test.Assert(!agent.NewAzureStorageTable(tableName), Utility.GenComparisonData("NewAzureStorageTable", 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(String.Format("Table name '{0}' is invalid.", tableName)), agent.ErrorMessages[0]); }
internal void StorageTableTest(Agent agent) { string NEW_TABLE_NAME = Utility.GenNameString("Washington"); //--------------New operation-------------- Test.Assert(!agent.NewAzureStorageTable(NEW_TABLE_NAME), Utility.GenComparisonData("NewAzureStorageTable", false)); CheckErrorOutput(agent); //--------------Get operation-------------- Test.Assert(!agent.GetAzureStorageTable(NEW_TABLE_NAME), Utility.GenComparisonData("GetAzureStorageTable", false)); CheckErrorOutput(agent); //--------------Remove operation-------------- Test.Assert(!agent.RemoveAzureStorageTable(NEW_TABLE_NAME), Utility.GenComparisonData("RemoveAzureStorageTable", false)); CheckErrorOutput(agent); }
/// <summary> /// Negative Functional Cases : for New-AzureStorageTable /// 1. Create a Table that already exists (Negative 3) /// </summary> internal void CreateExistingTable(Agent agent) { string TABLE_NAME = Utility.GenNameString("existing"); // create table if not exists CloudTable table = _StorageAccount.CreateCloudTableClient().GetTableReference(TABLE_NAME); table.CreateIfNotExists(); try { //--------------New operation-------------- Test.Assert(!agent.NewAzureStorageTable(TABLE_NAME), Utility.GenComparisonData("NewAzureStorageTable", 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("Table '{0}' already exists.", TABLE_NAME)), agent.ErrorMessages[0]); } finally { // Recover the environment table.DeleteIfExists(); } }
/// <summary> /// Functional Cases : for New-AzureStorageTable /// 1. Create a list of new Tables (Positive 2) /// 2. Create a list of Tables that already exist (Negative 4) /// 3. Create a list of Tables that some of them already exist (Negative 5) /// /// Functional Cases : for Get-AzureStorageTable /// 4. Get a list of Tables by using wildcards in the name (Positive 4) /// 5. Get a list of tables by using Prefix parameter (Positive 2) /// /// Functional Cases : for Remove-AzureStorageTable /// 6. Remove a list of existing Tables by using pipeline (Positive 4) /// </summary> internal void TableListOperations(Agent agent) { string PREFIX = Utility.GenNameString("uniqueprefix"); string[] TABLE_NAMES = new string[] { Utility.GenNameString(PREFIX), Utility.GenNameString(PREFIX), Utility.GenNameString(PREFIX) }; // PART_EXISTING_NAMES differs only the last element with Table_NAMES string[] PARTLY_EXISTING_NAMES = new string[TABLE_NAMES.Length]; Array.Copy(TABLE_NAMES, PARTLY_EXISTING_NAMES, TABLE_NAMES.Length - 1); PARTLY_EXISTING_NAMES[TABLE_NAMES.Length - 1] = Utility.GenNameString(PREFIX); string[] MERGED_NAMES = TABLE_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.Table, name)); } CloudTableClient tableClient = _StorageAccount.CreateCloudTableClient(); // Check if all the above Tables have been removed foreach (string name in MERGED_NAMES) { CloudTable Table = tableClient.GetTableReference(name); Table.DeleteIfExists(); } //--------------1. New operation-------------- Test.Assert(agent.NewAzureStorageTable(TABLE_NAMES), Utility.GenComparisonData("NewAzureStorageTable", true)); // Verification for returned values Test.Assert(agent.Output.Count == TABLE_NAMES.Count(), "{0} row returned : {1}", TABLE_NAMES.Count(), agent.Output.Count); // Check if all the above tables have been created foreach (string name in TABLE_NAMES) { CloudTable table = tableClient.GetTableReference(name); Test.Assert(table.Exists(), "table {0} should exist", name); } try { //--------------2. New operation-------------- Test.Assert(!agent.NewAzureStorageTable(TABLE_NAMES), Utility.GenComparisonData("NewAzureStorageTable", 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 TABLE_NAMES) { Test.Assert(agent.ErrorMessages[i].Equals(String.Format("Table '{0}' already exists.", name)), agent.ErrorMessages[i]); ++i; } //--------------3. New operation-------------- Test.Assert(!agent.NewAzureStorageTable(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageTable", false)); // Verification for returned values Test.Assert(agent.Output.Count == 1, "1 row returned : {0}", agent.Output.Count); // Check if all the above tables have been created foreach (string name in TABLE_NAMES) { CloudTable table = tableClient.GetTableReference(name); Test.Assert(table.Exists(), "table {0} should exist", name); } //--------------4. Get operation-------------- Test.Assert(agent.GetAzureStorageTable("*" + PREFIX + "*"), Utility.GenComparisonData("GetAzureStorageTable", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudTableClient().ListTables(PREFIX)); // use Prefix parameter Test.Assert(agent.GetAzureStorageTableByPrefix(PREFIX), Utility.GenComparisonData("GetAzureStorageTableByPrefix", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudTableClient().ListTables(PREFIX)); } finally { //--------------5. Remove operation-------------- Test.Assert(agent.RemoveAzureStorageTable(MERGED_NAMES), Utility.GenComparisonData("RemoveAzureStorageTable", true)); // Check if all the above tables have been removed foreach (string name in TABLE_NAMES) { CloudTable table = tableClient.GetTableReference(name); Test.Assert(!table.Exists(), "table {0} should not exist", name); } } }
/// <summary> /// Functional Cases : for New-AzureStorageTable /// 1. Create a list of new Tables (Positive 2) /// 2. Create a list of Tables that already exist (Negative 4) /// 3. Create a list of Tables that some of them already exist (Negative 5) /// /// Functional Cases : for Get-AzureStorageTable /// 4. Get a list of Tables by using wildcards in the name (Positive 4) /// 5. Get a list of tables by using Prefix parameter (Positive 2) /// /// Functional Cases : for Remove-AzureStorageTable /// 6. Remove a list of existing Tables by using pipeline (Positive 4) /// </summary> internal void TableListOperations(Agent agent) { string PREFIX = Utility.GenNameString("uniqueprefix"); string[] TABLE_NAMES = new string[] { Utility.GenNameString(PREFIX), Utility.GenNameString(PREFIX), Utility.GenNameString(PREFIX) }; // PART_EXISTING_NAMES differs only the last element with Table_NAMES string[] PARTLY_EXISTING_NAMES = new string[TABLE_NAMES.Length]; Array.Copy(TABLE_NAMES, PARTLY_EXISTING_NAMES, TABLE_NAMES.Length - 1); PARTLY_EXISTING_NAMES[TABLE_NAMES.Length - 1] = Utility.GenNameString(PREFIX); string[] MERGED_NAMES = TABLE_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.Table, name)); } CloudTableClient tableClient = _StorageAccount.CreateCloudTableClient(); // Check if all the above Tables have been removed foreach (string name in MERGED_NAMES) { CloudTable Table = tableClient.GetTableReference(name); Table.DeleteIfExists(); } //--------------1. New operation-------------- Test.Assert(agent.NewAzureStorageTable(TABLE_NAMES), Utility.GenComparisonData("NewAzureStorageTable", true)); // Verification for returned values Test.Assert(agent.Output.Count == TABLE_NAMES.Count(), "{0} row returned : {1}", TABLE_NAMES.Count(), agent.Output.Count); // Check if all the above tables have been created foreach (string name in TABLE_NAMES) { CloudTable table = tableClient.GetTableReference(name); Test.Assert(table.Exists(), "table {0} should exist", name); } try { //--------------2. New operation-------------- Test.Assert(!agent.NewAzureStorageTable(TABLE_NAMES), Utility.GenComparisonData("NewAzureStorageTable", 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 TABLE_NAMES) { Test.Assert(agent.ErrorMessages[i].Equals(String.Format("Table '{0}' already exists.", name)), agent.ErrorMessages[i]); ++i; } //--------------3. New operation-------------- Test.Assert(!agent.NewAzureStorageTable(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageTable", false)); // Verification for returned values Test.Assert(agent.Output.Count == 1, "1 row returned : {0}", agent.Output.Count); // Check if all the above tables have been created foreach (string name in TABLE_NAMES) { CloudTable table = tableClient.GetTableReference(name); Test.Assert(table.Exists(), "table {0} should exist", name); } //--------------4. Get operation-------------- Test.Assert(agent.GetAzureStorageTable("*" + PREFIX + "*"), Utility.GenComparisonData("GetAzureStorageTable", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudTableClient().ListTables(PREFIX)); // use Prefix parameter Test.Assert(agent.GetAzureStorageTableByPrefix(PREFIX), Utility.GenComparisonData("GetAzureStorageTableByPrefix", true)); // Verification for returned values agent.OutputValidation(_StorageAccount.CreateCloudTableClient().ListTables(PREFIX)); } finally { //--------------5. Remove operation-------------- Test.Assert(agent.RemoveAzureStorageTable(MERGED_NAMES), Utility.GenComparisonData("RemoveAzureStorageTable", true)); // Check if all the above tables have been removed foreach (string name in TABLE_NAMES) { CloudTable table = tableClient.GetTableReference(name); Test.Assert(!table.Exists(), "table {0} should not exist", name); } } }