public async Task GetRecordCount_Returns_ExpectedNumber_Of_Records_Older_Than_Given_DateTime(int recordsToInsert, int oldRecordCount) { // arrange List <string> partitionKeys = new List <string>(); for (int i = 0; i < oldRecordCount; i++) { partitionKeys.Add(i.ToString()); } TableDataGenerator generator = new TableDataGenerator(accountName, accountKey, tableName); await generator.AddRows(partitionKeys, 1); Thread.Sleep(1000); DateTime offset = DateTime.Now; partitionKeys.Clear(); for (int i = oldRecordCount; i < recordsToInsert; i++) { partitionKeys.Add(i.ToString()); } await generator.AddRows(partitionKeys, 1); Assert.Equal(oldRecordCount, await helper.GetRecordCount(offset)); }
public async Task DeleteOldRecordsWithoutPartition(int recordsToInsert, int recordsToDelete) { // arrange List <string> partitionKeys = new List <string>(); for (int i = 0; i < recordsToDelete; i++) { partitionKeys.Add(i.ToString()); } TableDataGenerator generator = new TableDataGenerator(accountName, accountKey, tableName); await generator.AddRows(partitionKeys, 1); Thread.Sleep(1000); DateTime offset = DateTime.Now; partitionKeys.Clear(); for (int i = recordsToDelete; i < recordsToInsert; i++) { partitionKeys.Add(i.ToString()); } await generator.AddRows(partitionKeys, 1); Assert.Equal(recordsToInsert, await helper.GetRecordCount(DateTime.Now)); // act await helper.Delete(offset); Assert.Equal(recordsToInsert - recordsToDelete, await helper.GetRecordCount(DateTime.Now)); await helper.Delete(DateTime.Now); }
/// <summary> /// Uncomment [Fact] attribute to execute. /// </summary> /// <returns></returns> //[Fact] public async Task AddRecords() { List <string> partitionKeys = new List <string>(); for (int i = 0; i < 5; i++) { partitionKeys.Add(i.ToString()); } var generator = new TableDataGenerator(accountName, accountKey, tableName); await generator.AddRows(partitionKeys, 50000); }
//[InlineData(5500, 3700)] public async Task DeleteOldRecordsForPartition(int recordsToInsert, int recordsToDelete) { string partitionKey = Guid.NewGuid().ToString(); // arrange TableDataGenerator generator = new TableDataGenerator(accountName, accountKey, tableName); await generator.AddRows(new List <string> { partitionKey }, recordsToDelete); Thread.Sleep(1000); DateTime offset = DateTime.Now; await generator.AddRows(new List <string> { partitionKey }, recordsToInsert - recordsToDelete); Assert.Equal(recordsToInsert, await helper.GetRecordCount(DateTime.Now, partitionKey)); // act await helper.Delete(offset, partitionKey); Assert.Equal((recordsToInsert - recordsToDelete), await helper.GetRecordCount(DateTime.Now, partitionKey)); }