added another 2nd document update to ensure it works consecutively
This commit is contained in:
+22
-12
@@ -308,7 +308,8 @@ namespace AspNetCore.Identity.MongoDbCore.Test
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
const string originalEmail = "original@email.com";
|
const string originalEmail = "original@email.com";
|
||||||
const string newEmail = "new@email.com";
|
const string newEmail1 = "new1@email.com";
|
||||||
|
const string newEmail2 = "new2@email.com";
|
||||||
var user = CreateTestUser();
|
var user = CreateTestUser();
|
||||||
user.Email = originalEmail;
|
user.Email = originalEmail;
|
||||||
var manager = CreateManager();
|
var manager = CreateManager();
|
||||||
@@ -317,18 +318,27 @@ namespace AspNetCore.Identity.MongoDbCore.Test
|
|||||||
Assert.NotNull(user);
|
Assert.NotNull(user);
|
||||||
Assert.Equal(originalEmail, userToUpdate.Email);
|
Assert.Equal(originalEmail, userToUpdate.Email);
|
||||||
|
|
||||||
// Act
|
// Act & Assert
|
||||||
// change the email to the new value
|
// change the email to the new value newEmail1
|
||||||
userToUpdate.Email = newEmail;
|
userToUpdate.Email = newEmail1;
|
||||||
userToUpdate.UserName = newEmail;
|
userToUpdate.UserName = newEmail1;
|
||||||
var updateResult = await manager.UpdateAsync(userToUpdate);
|
var updateResult1 = await manager.UpdateAsync(userToUpdate);
|
||||||
Assert.True(updateResult.Succeeded);
|
Assert.True(updateResult1.Succeeded);
|
||||||
|
var updatedUser1 = await manager.FindByIdAsync(user.Id);
|
||||||
|
Assert.NotNull(updatedUser1);
|
||||||
|
Assert.Equal(newEmail1, updatedUser1.Email);
|
||||||
|
Assert.Equal(newEmail1, updatedUser1.UserName);
|
||||||
|
|
||||||
// Assert
|
// change the email to the new value newEmail2
|
||||||
var updatedUser = await manager.FindByIdAsync(user.Id);
|
userToUpdate.Email = newEmail2;
|
||||||
Assert.NotNull(updatedUser);
|
userToUpdate.UserName = newEmail2;
|
||||||
Assert.Equal(newEmail, updatedUser.Email);
|
var updateResult2 = await manager.UpdateAsync(userToUpdate);
|
||||||
Assert.Equal(newEmail, updatedUser.UserName);
|
Assert.True(updateResult2.Succeeded);
|
||||||
|
|
||||||
|
var updatedUser2 = await manager.FindByIdAsync(user.Id);
|
||||||
|
Assert.NotNull(updatedUser2);
|
||||||
|
Assert.Equal(newEmail2, updatedUser2.Email);
|
||||||
|
Assert.Equal(newEmail2, updatedUser2.UserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override MongoDbIdentityUser CreateTestUser(string namePrefix = "", string email = "", string phoneNumber = "",
|
protected override MongoDbIdentityUser CreateTestUser(string namePrefix = "", string email = "", string phoneNumber = "",
|
||||||
|
|||||||
Reference in New Issue
Block a user