public void ShouldFailToRegister()
 {
     var error = string.Empty;
     membershipService.CreateUser("test", "password", "[email protected]", out error).Returns(false);
     var controller = CreateController();
     var model = new RegisterModel
     {
         UserName = "******",
         Password = "******",
         Email = "[email protected]"
     };
     var actionResult = controller.Register(model);
     actionResult.AssertViewRendered().WithViewData<RegisterModel>();
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var error = string.Empty;
                if (membershipService.CreateUser(model.UserName,model.Password,model.Email,out error))
                {
                    authenticationService.SetAuthorizationCredentials(model.UserName,false);
                    return RedirectToAction("Index", "Home");
                }

                ModelState.AddModelError("", error);

            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public void ShouldRegister()
 {
     string error;
     membershipService.CreateUser("test", "password", "[email protected]", out error).Returns(true);
     var controller = CreateController();
     var model = new RegisterModel
                     {
                         UserName = "******",
                         Password ="******",
                         Email = "[email protected]"
                     };
     var actionResult = controller.Register(model);
     actionResult.AssertActionRedirect();
 }
        public void ShouldRegister()
        {
            const string userName = "******";
            const string password = "******";
            const string email = "[email protected]";

            string error;
            membershipService.CreateUser(userName, password, email, out error).Returns(true);

            var controller = CreateController();
            var model = new RegisterModel
                            {
                                UserName = userName,
                                Password = password,
                                Email = email
                            };
            var actionResult = controller.Register(model);
            actionResult.AssertActionRedirect();
        }