public async Task UpdateApiResourceAsync() { 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); //Get new api resource var newApiResource = await context.ApiResources.Where(x => x.Id == apiResource.Id).SingleOrDefaultAsync(); //Assert new api resource newApiResource.ShouldBeEquivalentTo(apiResource, options => options.Excluding(o => o.Id)); //Detached the added item context.Entry(newApiResource).State = EntityState.Detached; //Generete new api resource with added item id var updatedApiResource = ApiResourceMock.GenerateRandomApiResource(newApiResource.Id); //Update api resource await apiResourceRepository.UpdateApiResourceAsync(updatedApiResource); //Get updated api resource var updatedApiResourceEntity = await context.ApiResources.Where(x => x.Id == updatedApiResource.Id).SingleAsync(); //Assert updated api resource updatedApiResource.ShouldBeEquivalentTo(updatedApiResourceEntity); } }