public async Task Recover_SendsRecoveryInformation() { service.IsLoggedIn(controller.User).Returns(false); validator.CanRecover(accountRecovery).Returns(true); service.Recover(accountRecovery).Returns("TestToken"); await controller.Recover(accountRecovery); String url = controller.Url.Action("Reset", "Auth", new { token = "TestToken" }, controller.Request.Url.Scheme); String body = String.Format(Messages.RecoveryEmailBody, url); String subject = Messages.RecoveryEmailSubject; String email = accountRecovery.Email; await mailClient.Received().SendAsync(email, subject, body); }
public async Task Recover_SendsRecoveryInformation() { service.IsLoggedIn(controller.User).Returns(false); validator.CanRecover(accountRecovery).Returns(true); service.Recover(accountRecovery).Returns("TestToken"); await controller.Recover(accountRecovery); String url = controller.Url.Action(nameof(Auth.Reset), nameof(Auth), new { token = "TestToken" }, controller.Request.Scheme); String subject = Message.For <AccountView>("RecoveryEmailSubject"); String body = Message.For <AccountView>("RecoveryEmailBody", url); String email = accountRecovery.Email; await mail.Received().SendAsync(email, subject, body); }
public void Recover_SendsRecoveryInformation() { HttpRequest request = HttpContext.Current.Request; String scheme = HttpContext.Current.Request.Url.Scheme; Account recoveredAccount = context.Set <Account>().Single(); UrlHelper urlHelper = new UrlHelper(request.RequestContext); AccountRecoveryView account = ObjectFactory.CreateAccountRecoveryView(); service.Recover(account); String expectedEmail = account.Email; String expectedEmailSubject = Messages.RecoveryEmailSubject; String recoveryUrl = urlHelper.Action("Reset", "Auth", new { token = recoveredAccount.RecoveryToken }, scheme); String expectedEmailBody = String.Format(Messages.RecoveryEmailBody, recoveryUrl); mailClient.Received().Send(expectedEmail, expectedEmailSubject, expectedEmailBody); }