public async Task MongoIdentityRole_CanAddAndRetrieveAndRemoveClaims() { using (var store = new MongoRoleClaimStore <MongoIdentityRole>(options, null, null, null)) { var mongoRole = new MongoIdentityRole("godRole"); var createOne = await store.CreateAsync(mongoRole, CancellationToken.None); var retrieveOne = await store.FindByNameAsync(mongoRole.Name, CancellationToken.None); Assert.NotNull(retrieveOne); var claim = new Claim(ClaimTypes.Role, "god"); await store.AddClaimAsync(retrieveOne, claim); var retrieveOneAgain = await store.FindByNameAsync(mongoRole.Name, CancellationToken.None); Assert.Single(retrieveOneAgain.Claims); retrieveOneAgain = await store.FindByIdAsync(retrieveOneAgain.Id, CancellationToken.None); await store.RemoveClaimAsync(retrieveOneAgain, retrieveOneAgain.Claims.Single().ToClaim()); retrieveOneAgain = await store.FindByIdAsync(retrieveOneAgain.Id, CancellationToken.None); Assert.Empty(retrieveOneAgain.Claims); } }
public async Task MongoIdentityRole_CanBeSavedAndRetrievedAndDeleted() { using (var store = new MongoRoleClaimStore <MongoIdentityRole>(options, null, null, null)) { var mongoRole = new MongoIdentityRole("godRole"); var createOne = await store.CreateAsync(mongoRole, CancellationToken.None); var retrieveOne = await store.FindByNameAsync(mongoRole.Name, CancellationToken.None); Assert.NotNull(retrieveOne); await store.DeleteAsync(retrieveOne); retrieveOne = await store.FindByNameAsync(mongoRole.Name, CancellationToken.None); Assert.Null(retrieveOne); } }