public async Task SaveManyAndDeleteMany() { var azureTable = new AzureTable <TestRow>(account, TableName); var row1 = new TestRow { PartitionKey = "partition_key_SaveManyAndDeleteMany", RowKey = "row_key_1_SaveManyAndDeleteMany", ETag = "*" }; var row2 = new TestRow { PartitionKey = "partition_key_SaveManyAndDeleteMany", RowKey = "row_key_2_SaveManyAndDeleteMany", ETag = "*" }; await azureTable.DeleteAsync(new[] { row1, row2 }); var rowsToDelete = await azureTable.GetByPartitionKeyAsync("partition_key_SaveManyAndDeleteMany"); Assert.AreEqual(0, rowsToDelete.Count()); row1.ETag = string.Empty; row2.ETag = string.Empty; await azureTable.AddAsync(new[] { row1, row2 }); var insertedRows = await azureTable.GetByPartitionKeyAsync("partition_key_SaveManyAndDeleteMany"); Assert.AreEqual(2, insertedRows.Count()); await azureTable.DeleteAsync(new[] { row1, row2 }); var actualRows = await azureTable.GetByPartitionKeyAsync("partition_key_SaveManyAndDeleteMany"); Assert.AreEqual(0, actualRows.Count()); }
public async Task GetByPartitionKey_Returns_SpecificEntities() { var azureTable = new AzureTable <TestRow>(account, TableName); var row1 = new TestRow { PartitionKey = "partition_key_1_GetByPartitionKey_Returns_SpecificEntities", RowKey = "row_key_1_GetByPartitionKey_Returns_SpecificEntities", Content = "content 1", ETag = "*" }; var row2 = new TestRow { PartitionKey = "partition_key_2_GetByPartitionKey_Returns_SpecificEntities", RowKey = "row_key_2_GetByPartitionKey_Returns_SpecificEntities", Content = "content 2", ETag = "*" }; var row3 = new TestRow { PartitionKey = "partition_key_2_GetByPartitionKey_Returns_SpecificEntities", RowKey = "row_key_3_GetByPartitionKey_Returns_SpecificEntities", Content = "content 3", ETag = "*" }; await azureTable.DeleteAsync(row1); await azureTable.DeleteAsync(row2); await azureTable.DeleteAsync(row3); await azureTable.AddAsync(row1); await azureTable.AddAsync(row2); await azureTable.AddAsync(row3); var retrievedRows = await azureTable.GetByPartitionKeyAsync("partition_key_2_GetByPartitionKey_Returns_SpecificEntities"); Assert.AreEqual(2, retrievedRows.Count()); Assert.AreEqual(row2.Content, retrievedRows.ToList()[0].Content); }
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); }
// // Summary: // Remove a user claim // // Parameters: // user: // // claim: public async Task RemoveClaimAsync(TUser user, Claim claim) { foreach (var userClaim in await m_userClaimTable.FindByPartitionKeyAsync <UserClaim>(user.Id)) { if (userClaim.ClaimType == claim.Type && userClaim.ClaimValue == claim.Value) { await m_userClaimTable.DeleteAsync(userClaim); } } }
public async Task GetByPartitionRowKey_Returns_SpecificEntity() { var azureTable = new AzureTable <TestRow>(account, TableName); var row1 = new TestRow { PartitionKey = "GetByPartitionRowKey_Returns_SpecificEntity", RowKey = "row_key_1_GetByPartitionRowKey_Returns_SpecificEntity", Content = "content 1", ETag = "*" }; var row2 = new TestRow { PartitionKey = "GetByPartitionRowKey_Returns_SpecificEntity", RowKey = "row_key_2_GetByPartitionRowKey_Returns_SpecificEntity", Content = "content 2", ETag = "*" }; var row3 = new TestRow { PartitionKey = "GetByPartitionRowKey_Returns_SpecificEntity", RowKey = "row_key_3_GetByPartitionRowKey_Returns_SpecificEntity", Content = "content 3", ETag = "*" }; await azureTable.DeleteAsync(new[] { row1, row2, row3 }); var rowsToDelete = await azureTable.GetByPartitionKeyAsync("GetByPartitionRowKey_Returns_SpecificEntity"); Assert.AreEqual(0, rowsToDelete.Count()); await azureTable.AddAsync(new[] { row1, row2, row3 }); var retrievedRow = await azureTable.GetByPartitionRowKeyAsync("GetByPartitionRowKey_Returns_SpecificEntity", "row_key_2_GetByPartitionRowKey_Returns_SpecificEntity"); Assert.AreEqual(row2.Content, retrievedRow.Content); }
public async Task AddOrUpdateMany() { var azureTable = new AzureTable <TestRow>(account, TableName); var row1 = new TestRow { PartitionKey = "partition_key_AddOrUpdateMany", RowKey = "row_key_1_AddOrUpdateMany", Content = "content 1", ETag = "*" }; var row2 = new TestRow { PartitionKey = "partition_key_AddOrUpdateMany", RowKey = "row_key_2_AddOrUpdateMany", Content = "content 2", ETag = "*" }; await azureTable.DeleteAsync(new[] { row1, row2 }); var rowsToDelete = await azureTable.GetByPartitionKeyAsync("partition_key_AddOrUpdateMany"); Assert.AreEqual(0, rowsToDelete.Count()); await azureTable.AddAsync(row1); var actualRows = await azureTable.GetByPartitionKeyAsync("partition_key_AddOrUpdateMany"); Assert.AreEqual(1, actualRows.Count()); row1.Content = "content modified"; await azureTable.AddOrUpdateAsync(new[] { row1, row2 }); var insertedRows = await azureTable.GetByPartitionKeyAsync("partition_key_AddOrUpdateMany"); Assert.AreEqual(2, insertedRows.Count()); TestRow updatedRow = await azureTable.GetByPartitionRowKeyAsync("partition_key_AddOrUpdateMany", row1.RowKey); Assert.IsNotNull(updatedRow); Assert.AreEqual("content modified", updatedRow.Content); }
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); }
// // Summary: // Removes the user login with the specified combination if it exists // // Parameters: // user: // // login: public async Task RemoveLoginAsync(TUser user, UserLoginInfo login) { var userLogin = await m_userLoginTable.FindAsync <UserLogin>(user.Id, login.ProviderKey); if (userLogin != null && userLogin.ProviderKey == login.ProviderKey) { await m_userLoginTable.DeleteAsync(userLogin); } var info = await m_lookupTable.FindAsync <LookupInfo>("LoginProvider_" + login.LoginProvider, login.ProviderKey); if (info != null) { await m_lookupTable.DeleteAsync(info); } }
public async Task DeleteAsync(TUser user) { await m_userTable.DeleteAsync(user); }
// // Summary: // Delete a role // // Parameters: // role: public async Task DeleteAsync(TRole role) { await m_roleTable.DeleteAsync(role); }