public async Task DeleteApiScopeAsync() { 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 apiScope = ApiResourceMock.GenerateRandomApiScope(0); //Add new api resource await apiResourceRepository.AddApiScopeAsync(apiResource.Id, apiScope); //Get new api resource var newApiScopes = await context.ApiScopes.Where(x => x.Id == apiScope.Id).SingleOrDefaultAsync(); //Assert new api resource newApiScopes.ShouldBeEquivalentTo(apiScope, options => options.Excluding(o => o.Id)); //Try delete it await apiResourceRepository.DeleteApiScopeAsync(newApiScopes); //Get new api scope var deletedApiScopes = await context.ApiScopes.Where(x => x.Id == newApiScopes.Id).SingleOrDefaultAsync(); //Assert if it exist deletedApiScopes.Should().BeNull(); } }