public void Login_POST_should_add_message_if_UserName_is_null()
        {
            var loginInput = new LoginInput { UserName = null };
            var controller = GetController();

            controller.Login(loginInput);

            userInterfaceManager.Verify(x => x.AddMessage(It.IsAny<string>()));
        }
        public void Login_POST_should_TrySignIn_if_Password_and_UserName_exist()
        {
            var loginInput = new LoginInput { Password = "******", UserName = "******" };
            var controller = GetController();

            controller.Login(loginInput);

            userSession.Verify(x => x.TrySignIn("u", "p"));
        }
        public void Login_POST_should_add_message_if_Password_is_empty_string()
        {
            var loginInput = new LoginInput { Password = "" };
            var controller = GetController();

            controller.Login(loginInput);

            userInterfaceManager.Verify(x => x.AddMessage(It.IsAny<string>()));
        }
Esempio n. 4
0
        public ActionResult Login(LoginInput loginInput)
        {
            try
            {
                Validate.NotNullOrEmpty(loginInput.UserName, "UserName");
                Validate.NotNullOrEmpty(loginInput.Password, "Password");

                userSession.TrySignIn(loginInput.UserName, loginInput.Password);

                return RedirectToAction<HomeController>(x => x.Index());
            }
            catch (Exception ex)
            {
                userInterfaceManager.AddMessage(ex.Message);
            }

            return View(loginInput);
        }
        public void Login_that_is_successful_should_go_to_home_page()
        {
            var loginInput = new LoginInput {Password = "******", UserName = "******"};
            var controller = GetController();

            var result = controller.Login(loginInput) as RedirectToRouteResult;

            result.ToAction<HomeController>(x => x.Index());
        }