public void GivenAResendVerificationCodeAction_WhenTheModelStateIsNotValid_ThenRendersTheDefaultView() { // Arrange var controller = new AccountController(CurrentUserManagerMock.Object, CurrentSignInManagerMock.Object); // Act var model = new ResendVerifyCodeViewModel(); controller.ModelState.AddModelError("", "Some kind of error"); controller.WithCallTo(c => c.ResendVerificationCode(model)) // Assert .ShouldRenderDefaultView(); }
public void GivenAResendVerificationCodeAction_WhenTheModelStateIsValid_ThenItRedirectsToVerifyRegsitrationCode() { // Arrange var controller = new AccountController(CurrentUserManagerMock.Object, CurrentSignInManagerMock.Object); // Act var model = new ResendVerifyCodeViewModel() { Email = "*****@*****.**", }; controller.WithCallTo(c => c.ResendVerificationCode(model)) // Assert .ShouldRedirectTo <AccountController>(c => c.VerifyRegistrationCode(new VerifyCodeViewModel())); }
public async Task <ActionResult> ResendVerificationCode(ResendVerifyCodeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var user = await UserManager.FindByEmailAsync(model.Email); if (user == null) { ModelState.AddModelError("", ApplicationMessages.UserNotFoundForGivenEmail); return(View(model)); } if (user.PhoneNumberConfirmed) { ModelState.AddModelError("", ApplicationMessages.UserAlreadyConfirmed); return(View(model)); } //await UserManager.RequestPhoneNumberConfirmationTokenAsync(user.Id); return(RedirectToAction("VerifyRegistrationCode", new { message = ApplicationMessages.VerificationCodeResent })); }