public void InvalidPassword()
 {
     var db = new FakeDatabase();
     var auth = new FakeFormAuthenticator();
     db.AddSet(TestUserData.Users);
     var cx = new FakeControllerContext();
     var controller = new UsersController(db, auth);
     controller.ControllerContext = cx;
     var result = controller.Login(new LoginViewModel() { UserName = "******", Password = "******", ReturnUrl = "/" }) as ViewResult;
     Assert.IsNotNull(result);
     Assert.IsNotNull(result.ViewData.ModelState[""]);
     Assert.IsNotNull(result.ViewData.ModelState[""].Errors);
     Assert.IsTrue(result.ViewData.ModelState[""].Errors.Count == 1);
     Assert.AreEqual("The User Name or password provided is incorrect.", result.ViewData.ModelState[""].Errors[0].ErrorMessage);
     Assert.AreEqual(1, db.LogAdded.Count);
     Assert.AreEqual(LogMessages.incorrectlogon, ((Log)db.LogAdded[0]).Message);
 }
 public void ValidUser()
 {
     var db = new FakeDatabase();
     var auth = new FakeFormAuthenticator();
     db.AddSet(TestUserData.Users);
     var controller = new UsersController(db, auth);
     controller.ControllerContext = new FakeControllerContext();
     var result = controller.Login(new LoginViewModel() { UserName = "******", Password = "******", ReturnUrl = "/" });
     Assert.AreEqual(typeof(RedirectResult), result.GetType());
     Assert.AreEqual(1, db.LogAdded.Count);
     Assert.AreEqual(LogMessages.logon, ((Log)db.LogAdded[0]).Message);
 }