public void LoginPostReturnsViewIfUsernameNotSpecified() { // Arrange var controller = GetAccountController(new UserProfile()); var model = new LogOnModel { UserName = "", Password = "******", RememberMe = false }; // Act var result = (ViewResult)controller.CallWithModelValidation(m => m.LogOn(model, null), model); // Assert var resultModel = (LogOnModel)result.Model; Assert.AreEqual(false, resultModel.RememberMe); Assert.AreEqual(ValidationStrings.UserNameRequired, result.ViewData.ModelState["username"].Errors[0].ErrorMessage); }
public void LoginPostReturnsViewIfUsernameOrPasswordIsIncorrect() { // Arrange var controller = GetAccountController(); var model = new LogOnModel { UserName = "******", Password = "******", RememberMe = true }; // Act var result = (ViewResult)controller.CallWithModelValidation(m => m.LogOn(model, null), model); // Assert var resultModel = (LogOnModel)result.Model; Assert.AreEqual(true, resultModel.RememberMe); Assert.AreEqual(ValidationStrings.UsernameOrPasswordIsIncorrect, result.ViewData.ModelState[String.Empty].Errors[0].ErrorMessage); }