public async Task DeleteUserClaimAsync() { 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 user var userDto = IdentityDtoMock.GenerateRandomUser(Guid.NewGuid()); await identityService.CreateUserAsync(userDto); //Get new user var user = await context.Users.Where(x => x.UserName == userDto.UserName).SingleOrDefaultAsync(); userDto.Id = user.Id; var newUserDto = await identityService.GetUserAsync(userDto); //Assert new user userDto.Should().BeEquivalentTo(newUserDto); //Generate random new user claim var userClaimDto = IdentityDtoMock.GenerateRandomUserClaim(0, userDto.Id); await identityService.CreateUserClaimsAsync(userClaimDto); //Get new user claim var claim = await context.UserClaims.Where(x => x.ClaimType == userClaimDto.ClaimType && x.ClaimValue == userClaimDto.ClaimValue).SingleOrDefaultAsync(); userClaimDto.ClaimId = claim.Id; var newUserClaim = await identityService.GetUserClaimAsync(userDto.Id, claim.Id); //Assert new user claim userClaimDto.Should().BeEquivalentTo(newUserClaim); await identityService.DeleteUserClaimsAsync(userClaimDto); //Get deleted user claim var deletedClaim = await context.UserClaims.Where(x => x.ClaimType == userClaimDto.ClaimType && x.ClaimValue == userClaimDto.ClaimValue).SingleOrDefaultAsync(); deletedClaim.Should().BeNull(); } }