public async Task RemoveRoleClaimAsync() { using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { var testUserManager = GetTestUserManager(context); var testRoleManager = GetTestRoleManager(context); IIdentityRepository identityRepository = new IdentityRepository(context, testUserManager, testRoleManager); var localizerIdentityResource = new IdentityServiceResources(); IIdentityService identityService = new IdentityService(identityRepository, localizerIdentityResource); //Generate random new role var roleDto = IdentityDtoMock.GenerateRandomRole(Guid.NewGuid()); await identityService.CreateRoleAsync(roleDto); //Get new role var role = await context.Roles.Where(x => x.Name == roleDto.Name).SingleOrDefaultAsync(); roleDto.Id = role.Id; var newRoleDto = await identityService.GetRoleAsync(roleDto); //Assert new role roleDto.Should().BeEquivalentTo(newRoleDto); //Generate random new role claim var roleClaimDto = IdentityDtoMock.GenerateRandomRoleClaim(0, roleDto.Id); await identityService.CreateRoleClaimsAsync(roleClaimDto); //Get new role claim var roleClaim = await context.RoleClaims.Where(x => x.ClaimType == roleClaimDto.ClaimType && x.ClaimValue == roleClaimDto.ClaimValue).SingleOrDefaultAsync(); roleClaimDto.ClaimId = roleClaim.Id; var newRoleClaimDto = await identityService.GetRoleClaimAsync(roleDto.Id, roleClaimDto.ClaimId); //Assert new role roleClaimDto.Should().BeEquivalentTo(newRoleClaimDto); await identityService.DeleteRoleClaimsAsync(roleClaimDto); var roleClaimToDelete = await context.RoleClaims.Where(x => x.ClaimType == roleClaimDto.ClaimType && x.ClaimValue == roleClaimDto.ClaimValue).SingleOrDefaultAsync(); //Assert removed role claim roleClaimToDelete.Should().BeNull(); } }