コード例 #1
0
 public void Init()
 {
     _contextMock = new Mock<IDbContext>();
                 _WebSecurity = new Mock<IWebSecurity>();
                 _logmod = new LogonModel();
                 _controller = new AccountController(_contextMock.Object, _WebSecurity.Object);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void Init()
 {
     _contextMock = new Mock<IDbContext>();
     _WebSecurity = new Mock<IWebSecurity>();
     _logmod = new LogonModel();
     _controller = new AssignmentController(_contextMock.Object);
     MapperConfig.Configure();
 }