我正在尝试为更改EmailID编写集成测试用例。
var token = await _userManager.GenerateChangeEmailTokenAsync(user, Input.Email);
var changeEmailResult = await _userManager.ChangeEmailAsync(user, Input.Email, token);
[Fact]
public async Task OnPostUpdateEmailAsync_WithValidInput_ShouldReturnSuccessMessage()
{
await _client.LoginAsync("test1@test.com", TestData.AlicePassword);
var response = await _client.SubmitAsync("./OnPostUpdateEmailAsync", new
{
Email = "testemail@test.com",
Password_ChangeEmail = "Password1"
});
response.AssertOnPage("./ChangeEmailPassword/UpdateEmail");
response.EnsureSuccessStatusCode();
var document = await response.GetDocument();
document.QuerySelectorAll(".alert-success")
.AssertCount(1)
.AssertHasTextEqual(
$"The email address has been changed successfully.");
}
[Fact]
public async Task OnPostResetPasswordAsync_WithWrongConfirmPassword_ShouldReturnErrorMessage()
{
await _client.LoginAsync(TestData.AliceEmail, TestData.AlicePassword);
var response = await _client.SubmitAsync("./ChangeEmailPassword/OnPostResetPasswordAsync", new
{
OldPassword = "OldPassword1",
Password = "NewPassword1",
ConfirmPassword = "NewPassword1"
});
response.AssertOnPage("./ChangeEmailPassword/ResetPassword");
response.EnsureSuccessStatusCode();
var document = await response.GetDocument();
document.QuerySelectorAll(".alert-danger")
.AssertCount(1)
.AssertHasTextEqual($"Error: The passwords do not match.");
}
它工作正常,但执行此操作后,所有其他测试用例均失败。我可以假设我们正在此处更改电子邮件ID,但对于其他人,它仍在寻找旧的电子邮件ID。可能是我在这里错了。要求大家,请帮助我。