public async Task DeleteAndAddAndGet() { var azureTable = new AzureTable <TestRow>(account, TableName); var row = new TestRow { PartitionKey = "partition_key_DeleteAndAddAndGet", RowKey = "row_key_DeleteAndAddAndGet", Content = "content" }; await azureTable.DeleteAsync(row); TestRow deletedRow = (await azureTable.GetByRowKeyAsync(row.RowKey)).SingleOrDefault(); Assert.IsNull(deletedRow); await azureTable.AddAsync(row); TestRow savedRow = await azureTable.GetByPartitionRowKeyAsync(row.PartitionKey, row.RowKey); Assert.IsNotNull(savedRow); Assert.AreEqual("content", savedRow.Content); await azureTable.DeleteAsync(row); TestRow actualRow = (await azureTable.GetByRowKeyAsync(row.RowKey)).SingleOrDefault(); Assert.IsNull(actualRow); }
public async Task AddOrUpdateUpdatesWhenExists() { var azureTable = new AzureTable <TestRow>(account, TableName); var row = new TestRow { PartitionKey = "partition_key_AddOrUpdateUpdatesWhenExists", RowKey = "row_key_AddOrUpdateUpdatesWhenExists", Content = "content" }; await azureTable.DeleteAsync(row); TestRow deletedRow = (await azureTable.GetByRowKeyAsync(row.RowKey)).SingleOrDefault(); Assert.IsNull(deletedRow); await azureTable.AddAsync(row); TestRow savedRow = await azureTable.GetByPartitionRowKeyAsync("partition_key_AddOrUpdateUpdatesWhenExists", row.RowKey); Assert.IsNotNull(savedRow); Assert.AreEqual("content", savedRow.Content); row.Content = "content modified"; await azureTable.AddOrUpdateAsync(row); TestRow updatedRow = await azureTable.GetByPartitionRowKeyAsync("partition_key_AddOrUpdateUpdatesWhenExists", row.RowKey); Assert.IsNotNull(updatedRow); Assert.AreEqual("content modified", updatedRow.Content); }
public async Task AddOrUpdateAddsWhenNotExists() { var account = CloudConfiguration.GetStorageAccount("DataConnectionString"); var azureTable = new AzureTable <TestRow>(account, TableName); var row = new TestRow { PartitionKey = "partition_key_AddOrUpdateAddsWhenNotExists", RowKey = "row_key_AddOrUpdateAddsWhenNotExists", Content = "content" }; await azureTable.DeleteAsync(row); TestRow deletedRow = (await azureTable.GetByRowKeyAsync(row.RowKey)).SingleOrDefault(); Assert.IsNull(deletedRow); await azureTable.AddOrUpdateAsync(row); TestRow savedRow = await azureTable.GetByPartitionRowKeyAsync("partition_key_AddOrUpdateAddsWhenNotExists", row.RowKey); Assert.IsNotNull(savedRow); Assert.AreEqual("content", savedRow.Content); }