public void TestingWithAllFieldsEmpty()
        {
            var viewModel = new UserLoginViewModel();
            var validator = new UserLoginViewModelValidator();
            var results = validator.Validate(viewModel);

            results.Errors.Count.Should().Be(2);
            results.Errors[0].ErrorMessage.Should().Be("'Login' deve ser preenchido.");
            results.Errors[1].ErrorMessage.Should().Be("'Senha' deve ser preenchido.");
        }
Ejemplo n.º 2
0
 public ActionResult Login(UserLoginViewModel userLoginViewModel)
 {
     if (ModelState.IsValid)
     {
         if (authProvider.Authenticate(userLoginViewModel.Login, userLoginViewModel.Password))
         {
             return RedirectToAction("Index", "Home");
         }
         else
         {
             ModelState.AddModelError("Login", "'Login' ou 'Senha' inválido(a).");
             return View();
         }
     }
     else
     {
         return View();
     }
 }