public async Task Test_Create_Add_Update_ScopeClaimsAsync() { var dao = new IdentityServer3CassandraDao(); await dao.EstablishConnectionAsync(); await dao.CreateTablesAsync(); await dao.TruncateTablesAsync(); var insertResult = await CassandraTestHelper.InsertTestData_Scopes(1); var queryNames = from item in insertResult select item.Record.Name; var nameList = queryNames.ToList(); var adminStore = new IdentityServer3AdminStore(); var stored = await adminStore.FindScopesAsync(nameList); Assert.AreEqual(stored.Count(), insertResult.Count); var scopeClaimComparer = ScopeClaimComparer.MinimalScopeClaimComparer; var scopeComparer = ScopeComparer.OrdinalIgnoreCase; var scope = await insertResult[0].Record.MakeIdentityServerScopeAsync(); var storedScope = stored.FirstOrDefault(); Assert.IsTrue(scopeComparer.Equals(scope, storedScope)); List <ScopeClaim> claims = new List <ScopeClaim>(); for (int i = 0; i < 2; ++i) { claims.Add(new ScopeClaim { Name = Guid.NewGuid().ToString(), AlwaysIncludeInIdToken = true, Description = Guid.NewGuid().ToString() }); } await adminStore.UpdateScopeByNameAsync(storedScope.Name, new List <PropertyValue>() { new PropertyValue() { Name = "Claims", Value = claims } }); stored = await adminStore.FindScopesAsync(nameList); storedScope = stored.FirstOrDefault(); Assert.IsTrue(scopeComparer.Equals(scope, storedScope)); var query = from item in storedScope.Claims where !claims.Contains(item, ScopeClaimComparer.DeepScopeClaimComparer) select item; var finalList = query.ToList(); Assert.IsTrue(finalList.Count == 0); // Do NOT update name foreach (var claim in claims) { claim.Description = Guid.NewGuid().ToString(); claim.AlwaysIncludeInIdToken = !claim.AlwaysIncludeInIdToken; } await adminStore.UpdateScopeClaimsAsync(storedScope.Name, claims); stored = await adminStore.FindScopesAsync(nameList); storedScope = stored.FirstOrDefault(); Assert.IsTrue(scopeComparer.Equals(scope, storedScope)); query = from item in storedScope.Claims where !claims.Contains(item, ScopeClaimComparer.DeepScopeClaimComparer) select item; finalList = query.ToList(); Assert.IsTrue(finalList.Count == 0); }