コード例 #1
0
        public async Task DeleteIdentityResourceAsync()
        {
            using (var context = new ConfigurationDbContext(_dbContextOptions, _storeOptions, _operationalStore))
            {
                IIdentityResourceRepository identityResourceRepository = new IdentityResourceRepository(context);

                //Generate random new identity resource
                var identityResource = IdentityResourceMock.GenerateRandomIdentityResource(0);

                //Add new identity resource
                await identityResourceRepository.AddIdentityResourceAsync(identityResource);

                //Get new identity resource
                var newIdentityResource = await context.IdentityResources.Where(x => x.Id == identityResource.Id).SingleAsync();

                //Assert new identity resource
                newIdentityResource.ShouldBeEquivalentTo(identityResource, options => options.Excluding(o => o.Id));

                //Delete identity resource
                await identityResourceRepository.DeleteIdentityResourceAsync(newIdentityResource);

                //Get deleted identity resource
                var deletedIdentityResource = await context.IdentityResources.Where(x => x.Id == identityResource.Id).SingleOrDefaultAsync();

                //Assert if it not exist
                deletedIdentityResource.Should().BeNull();
            }
        }