title: How to mock Controller.User using moq
body: <p>I have a couple of ActionMethods that queries the Controller.User for its role like this</p>
  
  <pre><code>bool isAdmin = User.IsInRole("admin");
  </code></pre>
  
  <p>acting conveniently on that condition.</p>
  
  <p>I'm starting to make tests for these methods with code like this</p>
  
  <pre><code>[TestMethod]
  public void HomeController_Index_Should_Return_Non_Null_ViewPage()
  {
      HomeController controller  = new HomePostController();
      ActionResult index = controller.Index();
  
      Assert.IsNotNull(index);
  }
  </code></pre>
  
  <p>and that Test Fails because Controller.User is not set.
  Any idea?</p>