public async Task UpdateApiScopeAsync() { 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; //Generate random new api scope var apiScope = ApiResourceMock.GenerateRandomApiScope(0); //Add new api scope await apiResourceRepository.AddApiScopeAsync(apiResource.Id, apiScope); //Detached the added item context.Entry(apiScope).State = EntityState.Detached; //Generete new api scope with added item id var updatedApiScope = ApiResourceMock.GenerateRandomApiScope(apiScope.Id); //Update api scope await apiResourceRepository.UpdateApiScopeAsync(apiResource.Id, updatedApiScope); //Get updated api scope var updatedApiScopeEntity = await context.ApiScopes.Where(x => x.Id == updatedApiScope.Id).SingleAsync(); //Assert updated api scope updatedApiScope.ShouldBeEquivalentTo(updatedApiScopeEntity); } }