public void RegistrationController_CreateAccountReturnsUser_ShouldRenderSuccessView()
        {
            var sut = new RegistrationController(_mrUserAccountServiceMock.Object);

            var regModel = new RegistrationModel();
            regModel.Email = "*****@*****.**";
            sut.WithCallTo(x => x.Index(regModel)).ShouldRenderView("Success");
        }
        public void RegistrationController_CreateAccountThrowsValidationException_ShouldRenderDefaultView()
        {
            var sut = new RegistrationController(_mrUserAccountServiceMock.Object);

            var regModel = new RegistrationModel();
            regModel.Email = "*****@*****.**";

            sut.WithCallTo(x => x.Index(regModel)).ShouldRenderDefaultView();
        }
        public void RegistrationController_CreateAccountReturnsNull_ShouldThrowError()
        {
            var sut = new RegistrationController(_mrUserAccountServiceMock.Object);

            var regModel = new RegistrationModel();

            ArgumentNullException ex = Assert.Throws<ArgumentNullException>(() => sut.Index(regModel));

            Assert.AreEqual(ex.ParamName, "account");
        }
        public void Registration_Index_RendersView()
        {
            var sut = new _Views_Registration_Index_cshtml{ };

            var model = new RegistrationModel();

            //@Html.AntiForgeryToken() needs HttpContext
            HttpContext.Current = new HttpContext(new HttpRequest("", "http://www.test.com", ""), new HttpResponse(null));
            HtmlDocument html = sut.RenderAsHtml(new HttpContextWrapper(HttpContext.Current), model);
        }
        public void RegistrationSuccess_CalledWithViewDataSignIn_RendersLoginLink()
        {
            var sut = new _Views_Registration_Success_cshtml {  };

            var model = new RegistrationModel();
            model.SignIn = "123456789";

            HtmlDocument html = sut.RenderAsHtml(model);

            var href = html.GetElementbyId("loginLink").Attributes["href"];

            Assert.AreEqual("/core/login?signin=123456789", href.Value);
        }
        public ActionResult Index(RegistrationModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var account = CreateAccount(model);
                    if (account == null) throw new ArgumentNullException(nameof(account));

                    return View("Success", model);
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            return View(model);
        }
        public void SubmitRegistration_WithEmailNotAlreadyInUse_ValidationErrorsContainsDuplicateEmailMesage()
        {
            var registerPage =
                BrowserHost.Instance.NavigateToInitialPage<RegistrationController, RegistrationPage>(
                    x => x.Index("9e2551b17d891245108b300484e4e9d3"));

            var registrationDetails = new RegistrationModel
            {
                SignIn = "9e2551b17d891245108b300484e4e9d3",
                First = "Fred",
                Last = "Smith",
                Email = "*****@*****.**",
                Password = "******",
                ConfirmPassword = "******"
            };

            var registeredPage = registerPage.SubmitRegistration<RegisteredPage>(registrationDetails);

            var registeredPageText = registeredPage.RegisteredMessage;

            Assert.That(registeredPageText, Is.EqualTo("Registration Success"));
        }
 protected MrUser CreateAccount(RegistrationModel model)
 {
     string tenant = _mrUserAccountService.DefaultTenant;
     var account = _mrUserAccountService.CreateAccount(tenant, model.Email, model.Password, model.Email);
     return account;
 }
 public ActionResult Index(string signin)
 {
     var model = new RegistrationModel();
     return View(model);
 }