public async Task <IActionResult> Index(ForgotPasswordViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var baseUrl = config.GetAppRootPath(); try { await passwordResetService.GenerateAndSendPasswordResetLink( model.EmailAddress.Trim(), baseUrl ); } catch (UserAccountNotFoundException) { ModelState.AddModelError("EmailAddress", "A user with this email could not be found"); return(View(model)); } catch (ResetPasswordInsertException) { return(new StatusCodeResult(500)); } return(RedirectToAction("Confirm")); }
public async Task Successful_email_submission_should_render_confirm_page() { // Given A.CallTo(() => passwordResetService.GenerateAndSendPasswordResetLink(A <string> ._, A <string> ._)) .Returns(Task.CompletedTask); // When var result = await controller.Index(new ForgotPasswordViewModel("*****@*****.**")); // Then result.Should().BeRedirectToActionResult().WithActionName("Confirm"); }