title: FormsAuthentication.SetAuthCookie mocking using Moq
body: <p>Hi i'm doing some unit test on my ASP.Net MVC2 project. I'm using Moq framework. In my LogOnController,</p>
  
  <pre><code>[HttpPost]
  public ActionResult LogOn(LogOnModel model, string returnUrl = "")
  {
    FormsAuthenticationService FormsService = new FormsAuthenticationService();
    FormsService.SignIn(model.UserName, model.RememberMe);
  
   }
  </code></pre>
  
  <p>In FormAuthenticationService class,</p>
  
  <pre><code>public class FormsAuthenticationService : IFormsAuthenticationService
      {
          public virtual void SignIn(string userName, bool createPersistentCookie)
          {
              if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot     be null or empty.", "userName");
              FormsAuthentication.SetAuthCookie(userName, createPersistentCookie);
          }
          public void SignOut()
          {
              FormsAuthentication.SignOut();
          }
      }
  </code></pre>
  
  <p>My problem is how can i avoid executing </p>
  
  <pre><code>FormsService.SignIn(model.UserName, model.RememberMe);
  </code></pre>
  
  <p>this line. Or is there any way to Moq </p>
  
  <pre><code> FormsService.SignIn(model.UserName, model.RememberMe);
  </code></pre>
  
  <p>using Moq framework <strong>without</strong> changing my ASP.Net MVC2 project.</p>