Пример #1
0
        public void SignIn_InvalidModel_RedirectToLoginAction()
        {
            var model = new LoginModel();

            var result = _homeController.SignIn(model);

            Assert.AreEqual("Login", result.RouteValues["action"]);
        }
Пример #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");
        }
Пример #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);
        }
Пример #4
0
        public void SignIn_ValidModelButUserDoesNotExist_RedirectToLoginPage()
        {
            var model = new LoginModel {Email = "*****@*****.**", Password = "******"};

            var result = _homeController.SignIn(model);

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