public void Init() { _contextMock = new Mock<IDbContext>(); _WebSecurity = new Mock<IWebSecurity>(); _logmod = new LogonModel(); _controller = new AccountController(_contextMock.Object, _WebSecurity.Object); }
public void Login_UserCanLogin() { string returnUrl = "/Home/Index"; string userName = "******"; string password = "******"; _WebSecurity.Setup(s => s.Login(userName, password, false)).Returns(true); SetupControllerForTests(_controller); var model = new LogonModel { UserName = userName, Password = password }; var result = _controller.Logon(model, returnUrl) as RedirectResult; Assert.NotNull(result); Assert.AreEqual(returnUrl, result.Url); }
public ActionResult Logon(LogonModel model, string returnUrl) { if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, model.RememberMe)) return RedirectToLocal(returnUrl); ModelState.AddModelError(string.Empty, "De gebruikersnaam of wachtwoord is niet correct."); return View(model); }
public void Init() { _contextMock = new Mock<IDbContext>(); _WebSecurity = new Mock<IWebSecurity>(); _logmod = new LogonModel(); _controller = new AssignmentController(_contextMock.Object); MapperConfig.Configure(); }