public async Task GetClientClaimAsync() { using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { IClientRepository clientRepository = new ClientRepository(context); //Generate random new client without id var client = ClientMock.GenerateRandomClient(0); //Add new client await clientRepository.AddClientAsync(client); //Get new client var clientEntity = await clientRepository.GetClientAsync(client.Id); //Assert new client clientEntity.Should().BeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random client claim var clientClaim = ClientMock.GenerateRandomClientClaim(0); //Add new client claim await clientRepository.AddClientClaimAsync(clientEntity.Id, clientClaim); //Get new client claim var newClientClaim = await clientRepository.GetClientClaimAsync(clientClaim.Id); newClientClaim.Should().BeEquivalentTo(clientClaim, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); } }
public async Task DeleteClientClaimAsync() { using (var context = new AdminDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { IClientRepository clientRepository = new ClientRepository(context); //Generate random new client without id var client = ClientMock.GenerateRandomClient(0); //Add new client await clientRepository.AddClientAsync(client); //Get new client var clientEntity = await clientRepository.GetClientAsync(client.Id); //Assert new client clientEntity.ShouldBeEquivalentTo(client, options => options.Excluding(o => o.Id)); //Generate random new Client Claim var clientClaim = ClientMock.GenerateRandomClientClaim(0); //Add new client claim await clientRepository.AddClientClaimAsync(clientEntity.Id, clientClaim); //Get new client claim var newClientClaim = await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync(); //Asert newClientClaim.ShouldBeEquivalentTo(clientClaim, options => options.Excluding(o => o.Id).Excluding(x => x.Client)); //Try delete it await clientRepository.DeleteClientClaimAsync(newClientClaim); //Get new client claim var deletedClientClaim = await context.ClientClaims.Where(x => x.Id == clientClaim.Id).SingleOrDefaultAsync(); //Assert deletedClientClaim.Should().BeNull(); } }