public async Task GetApiSecretAsync() { using (var context = new ConfigurationDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { IApiResourceRepository apiResourceRepository = new ApiResourceRepository(context); //Generate random new api resource var apiResource = ApiResourceMock.GenerateRandomApiResource(0); //Add new api resource await apiResourceRepository.AddApiResourceAsync(apiResource); //Generate random new api secret var apiSecret = ApiResourceMock.GenerateRandomApiSecret(0); //Add new api secret await apiResourceRepository.AddApiSecretAsync(apiResource.Id, apiSecret); //Get new api secret var newApiSecret = await apiResourceRepository.GetApiSecretAsync(apiSecret.Id); //Assert new api secret newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id)); } }
public async Task DeleteApiSecretAsync() { using (var context = new ConfigurationDbContext(_dbContextOptions, _storeOptions, _operationalStore)) { IApiResourceRepository apiResourceRepository = new ApiResourceRepository(context); //Generate random new api resource var apiResource = ApiResourceMock.GenerateRandomApiResource(0); //Add new api resource await apiResourceRepository.AddApiResourceAsync(apiResource); //Generate random new api scope var apiSecret = ApiResourceMock.GenerateRandomApiSecret(0); //Add new api secret await apiResourceRepository.AddApiSecretAsync(apiResource.Id, apiSecret); //Get new api resource var newApiSecret = await context.ApiSecrets.Where(x => x.Id == apiSecret.Id).SingleOrDefaultAsync(); //Assert new api resource newApiSecret.ShouldBeEquivalentTo(apiSecret, options => options.Excluding(o => o.Id)); //Try delete it await apiResourceRepository.DeleteApiSecretAsync(newApiSecret); //Get deleted api secret var deletedApiSecret = await context.ApiSecrets.Where(x => x.Id == newApiSecret.Id).SingleOrDefaultAsync(); //Assert if it exist deletedApiSecret.Should().BeNull(); } }