public async Task Test_Find_Scope_by_Name_Async() { var dao = new IdentityServer3CassandraDao(); await dao.EstablishConnectionAsync(); var actualScope1 = new Scope() { Name = Guid.NewGuid().ToString(), Type = ScopeType.Identity }; await dao.UpsertScopeAsync(new FlattenedScopeRecord(new FlattenedScopeHandle(actualScope1))); var actualScope2 = new Scope() { Name = Guid.NewGuid().ToString(), Type = ScopeType.Resource }; await dao.UpsertScopeAsync(new FlattenedScopeRecord(new FlattenedScopeHandle(actualScope2))); var scope = await dao.FindScopeByNameAsync(actualScope1.Name); Assert.AreEqual(scope.Type, actualScope1.Type); Assert.AreEqual(scope.Name, actualScope1.Name); scope = await dao.FindScopeByNameAsync(actualScope2.Name); Assert.AreEqual(scope.Type, actualScope2.Type); Assert.AreEqual(scope.Name, actualScope2.Name); }
public async Task Test_Create_Find_Delete_Scope_Async() { var dao = new IdentityServer3CassandraDao(); await dao.EstablishConnectionAsync(); var insertResult = await CassandraTestHelper.InsertTestData_Scopes(1); var queryNames = from item in insertResult select item.Record.Name; var nameList = queryNames.ToList(); var result = await dao.FindScopesByNamesAsync(nameList); Assert.AreEqual(result.Count(), insertResult.Count); var scope = await dao.FindScopeByNameAsync(nameList[0]); Assert.IsNotNull(scope); Assert.AreEqual(scope.Name, nameList[0]); FlattenedScopeRecord fsr = new FlattenedScopeRecord(new FlattenedScopeHandle(scope)); scope = await dao.FindScopeByIdAsync(fsr.Id); Assert.IsNotNull(scope); Assert.AreEqual(scope.Name, nameList[0]); await dao.DeleteScopeAsync(scope); scope = await dao.FindScopeByNameAsync(scope.Name); Assert.IsNull(scope); scope = await dao.FindScopeByIdAsync(fsr.Id); Assert.IsNull(scope); }