public static Equal ( IEnumerable |
||
expected | IEnumerable |
|
actual | IEnumerable |
|
Résultat | void |
public async Task Multiple_users_for_claim_returns_list_with_matching_users() { // arrange var user1 = new IdentityUser("Multiple_users_for_claim_returns_list_with_matching_users-1"); user1.Claims.Add(_identityClaim1); user1.Claims.Add(_identityClaim2); await _userStore.CreateAsync(user1); var user2 = new IdentityUser("Multiple_users_for_claim_returns_list_with_matching_users-2"); user2.Claims.Add(_identityClaim1); await _userStore.CreateAsync(user2); var user3 = new IdentityUser("Multiple_users_for_claim_returns_list_with_matching_users-3"); user3.Claims.Add(_identityClaim2); await _userStore.CreateAsync(user3); // act var result = await _userStore.GetUsersForClaimAsync(_claim1); // assert Assert.Equal(2, result.Count); IdentityUserAssert.Equal(new List <IdentityUser> { user1, user2 }, result); }
public static void Equal(IEnumerable <IdentityUser> expected, IEnumerable <IdentityUser> actual) { Assert.True((expected == null && actual == null) || (expected != null && actual != null)); Assert.Equal(expected.Count(), actual.Count()); foreach (var e in expected) { var act = actual.SingleOrDefault(a => a.Id == e.Id); IdentityUserAssert.Equal(e, act); } }
public async Task Case_insensitive_userName_returns_IdentityUser() { // arrange var user = new IdentityUser("Case_insensitive_normalizedUserName_returns_IdentityUser"); await _userStore.CreateAsync(user); // act var result = await _userStore.FindByNameAsync(user.UserName.ToUpper()); // assert IdentityUserAssert.Equal(user, result); }
public async Task Known_normalizedUserName_returns_IdentityUser() { // arrange var user = new IdentityUser("Known_normalizedUserName_returns_IdentityUser"); await _userStore.CreateAsync(user); // act var result = await _userStore.FindByNameAsync(user.UserName); // assert IdentityUserAssert.Equal(user, result); }
public async Task Known_userId_returns_IdentityUser() { // arrange var user = new IdentityUser("Known_userId_returns_IdentityUser"); await _userStore.CreateAsync(user); // act var result = await _userStore.FindByIdAsync(user.Id); // assert IdentityUserAssert.Equal(user, result); }
public async Task Update_user_that_does_not_already_exists_inserts_new_record_and_returns_Success() { // arrange var user = new IdentityUser("Update_user_that_does_not_already_exists_inserts_new_record_and_returns_Success"); // act var result = await _userStore.UpdateAsync(user); // assert IdentityResultAssert.IsSuccess(result); var userFromDb = await _userCollection.Find(x => x.Id == user.Id).SingleOrDefaultAsync(); IdentityUserAssert.Equal(user, userFromDb); }
public async Task Can_update_user_multiple_times() { // arrange var user = new IdentityUser("Can_update_user_multiple_times"); await _userStore.CreateAsync(user); // act user.Claims.Add(_identityClaim1); var result1 = await _userStore.UpdateAsync(user); user.UserName = user.UserName + " different"; var result2 = await _userStore.UpdateAsync(user); // assert IdentityResultAssert.IsSuccess(result1); IdentityResultAssert.IsSuccess(result2); var userFromDb = await _userCollection.Find(x => x.Id == user.Id).SingleOrDefaultAsync(); IdentityUserAssert.Equal(user, userFromDb); }
public async Task Update_user_returns_Success() { // arrange var user = new IdentityUser("Update_user_returns_Success"); user.Claims.Add(_identityClaim1); // initial user creation await _userStore.CreateAsync(user); user.UserName = user.UserName + " different"; user.Claims.Add(_identityClaim2); // act var result = await _userStore.UpdateAsync(user); // assert IdentityResultAssert.IsSuccess(result); var userFromDb = await _userCollection.Find(x => x.Id == user.Id).SingleOrDefaultAsync(); IdentityUserAssert.Equal(user, userFromDb); }
public async Task One_user_for_claim_returns_list_with_matching_user() { // arrange var user1 = new IdentityUser("One_user_for_claim_returns_list_with_matching_user-1"); user1.Claims.Add(_identityClaim1); user1.Claims.Add(_identityClaim2); await _userStore.CreateAsync(user1); var user2 = new IdentityUser("One_user_for_claim_returns_list_with_matching_user-2"); user2.Claims.Add(_identityClaim1SameType); user2.Claims.Add(_identityClaim2); await _userStore.CreateAsync(user2); // act var result = await _userStore.GetUsersForClaimAsync(_claim1); // assert Assert.Equal(1, result.Count); IdentityUserAssert.Equal(user1, result.Single()); }