title: Model state validation in unit tests
body: <p>I am writing a unit test for a controller like this:</p>
  
  <pre><code>public HttpResponseMessage PostLogin(LoginModel model)
  {
      if (!ModelState.IsValid)
          return new HttpResponseMessage(HttpStatusCode.BadRequest);
  }
  </code></pre>
  
  <p>the model looks like:</p>
  
  <pre><code>public class LoginModel
  {
      [Required]
      public string Username { set; get; }
      [Required]
      public string Password { set; get; }
  }
  </code></pre>
  
  <p>Then I have unit test like this one:</p>
  
  <pre><code>[TestMethod]
  public void TestLogin_InvalidModel()
  {
      AccountController controller = CreateAccountController();
  
      ...
      var response = controller.PostLogin(new LoginModel() {  });
  
      Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
  
  }
  </code></pre>
  
  <p>Actually the ModelState is validated... which is weird for me as both fields are required...
  Could anybody advise?</p>