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 Known_normalizedUserName_returns_IdentityUser() { // arrange var user = new IdentityUser("Known_normalizedUserName_returns_IdentityUser"); user.NormalizedUserName = user.UserName; await _userStore.CreateAsync(user); // act var result = await _userStore.FindByNameAsync(user.NormalizedUserName); // 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 Create_user_returns_Success() { // arrange var user = new IdentityUser("Create_user_returns_Success"); // act var result = await _userStore.CreateAsync(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); }