Ejemplo n.º 1
0
        public void SignIn_InvalidModel_RedirectToLoginAction()
        {
            var model = new LoginModel();

            var result = _homeController.SignIn(model);

            Assert.AreEqual("Login", result.RouteValues["action"]);
        }
Ejemplo n.º 2
0
        public RedirectToRouteResult SignIn(LoginModel model)
        {
            if (!ModelState.IsValid || (String.IsNullOrEmpty(model.Email) || String.IsNullOrEmpty(model.Password)))
                return RedirectToAction("Login");

            var user = _userService.LoginUser(model.Email, model.Password);

            if (user == null)
                return RedirectToAction("Login");

            _authenticationService.Login(model.Email);

            return RedirectToAction("Index", "Article");
        }
Ejemplo n.º 3
0
        public void SignIn_ValidModelAndUserExists_RedirectToIndexPage()
        {
            _fakeUserService.Setup(x => x.LoginUser(It.IsAny<string>(), It.IsAny<string>())).Returns(new User());

            var model = new LoginModel {Email = "*****@*****.**", Password = "******"};

            var result = _homeController.SignIn(model);

            var rvd = new RouteValueDictionary
            {
                {"action", "Index" },
                {"controller", "Article"}
            };

            Assert.AreEqual(rvd, result.RouteValues);
        }
Ejemplo n.º 4
0
        public void SignIn_ValidModelButUserDoesNotExist_RedirectToLoginPage()
        {
            var model = new LoginModel {Email = "*****@*****.**", Password = "******"};

            var result = _homeController.SignIn(model);

            Assert.AreEqual("Login", result.RouteValues["action"]);
        }