public void EnumerateAllTables() { //--------------Get operation-------------- Test.Assert(CommandAgent.GetAzureStorageTable(""), Utility.GenComparisonData("EnumerateAllTables", true)); // Verification for returned values CommandAgent.OutputValidation(StorageAccount.CreateCloudTableClient().ListTables()); }
public void GetNonExistingTable() { string TABLE_NAME = Utility.GenNameString("nonexisting"); // Delete the table if it exists CloudTable table = StorageAccount.CreateCloudTableClient().GetTableReference(TABLE_NAME); table.DeleteIfExists(); //--------------Get operation-------------- Test.Assert(!CommandAgent.GetAzureStorageTable(TABLE_NAME), Utility.GenComparisonData("GetAzureStorageTable", false)); // Verification for returned values Test.Assert(CommandAgent.Output.Count == 0, "Only 0 row returned : {0}", CommandAgent.Output.Count); CommandAgent.ValidateErrorMessage(MethodBase.GetCurrentMethod().Name, TABLE_NAME); }
public void TableListOperations() { 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); 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.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(CommandAgent.NewAzureStorageTable(TABLE_NAMES), Utility.GenComparisonData("NewAzureStorageTable", true)); // Verification for returned values if (multiOutput) { Test.Assert(CommandAgent.Output.Count == TABLE_NAMES.Count(), "{0} row returned : {1}", TABLE_NAMES.Count(), CommandAgent.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(!CommandAgent.NewAzureStorageTable(TABLE_NAMES), Utility.GenComparisonData("NewAzureStorageTable", false)); // Verification for returned values if (multiOutput) { Test.Assert(CommandAgent.Output.Count == 0, "0 row returned : {0}", CommandAgent.Output.Count); } int i = 0; foreach (string name in TABLE_NAMES) { if (multiOutput) { Test.Assert(CommandAgent.ErrorMessages[i].Contains(String.Format("Table '{0}' already exists.", name)), CommandAgent.ErrorMessages[i]); } else { Test.Assert(CommandAgent.ErrorMessages[0].Contains("The table specified already exists"), CommandAgent.ErrorMessages[0]); } ++i; } //--------------3. New operation-------------- Test.Assert(!CommandAgent.NewAzureStorageTable(PARTLY_EXISTING_NAMES), Utility.GenComparisonData("NewAzureStorageTable", false)); // Verification for returned values if (multiOutput) { Test.Assert(CommandAgent.Output.Count == 1, "1 row returned : {0}", CommandAgent.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-------------- if (multiOutput) { Test.Assert(CommandAgent.GetAzureStorageTable("*" + PREFIX + "*"), Utility.GenComparisonData("GetAzureStorageTable", true)); // Verification for returned values CommandAgent.OutputValidation(StorageAccount.CreateCloudTableClient().ListTables(PREFIX)); } // use Prefix parameter Test.Assert(CommandAgent.GetAzureStorageTableByPrefix(PREFIX), Utility.GenComparisonData("GetAzureStorageTableByPrefix", true)); // Verification for returned values CommandAgent.OutputValidation(StorageAccount.CreateCloudTableClient().ListTables(PREFIX)); } finally { //--------------5. Remove operation-------------- Test.Assert(CommandAgent.RemoveAzureStorageTable(TABLE_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); } } }