title: Mock User Agent
body: <p>I'm writing unit tests in which I need a fake HttpContext. I used the HttpSimulator from Phil Haack (http://haacked.com/archive/2007/06/19/unit-tests-web-code-without-a-web-server-using-httpsimulator.aspx).
  But an function in the Sitecore api throws an exception on the following code:</p>
  
  <pre><code>request.Browser.Browser.IndexOf("IE", StringComparison.OrdinalIgnoreCase) &gt; -1;
  </code></pre>
  
  <p>I debugged my code and the request.Browser.Browser is empty. I tried to fill the property with Moq but I get an exception. I also tried to add it as a header.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>using (HttpSimulator simulator = new HttpSimulator("/", "localpath"))
  {
      //NameValueCollection nvc = new NameValueCollection { { "User-Agent", "IE" } };
      //simulator.SimulateRequest(new Uri("http://www.foo.bar"), HttpVerb.GET, nvc);
      simulator.SimulateRequest();        
  
      var browserMock = new Mock&lt;HttpBrowserCapabilities&gt;();
      browserMock.SetupAllProperties();
      //browserMock.SetupProperty(b =&gt; b.Browser, "IE");
      HttpContext.Current.Request.Browser = browserMock.Object;
  }
  </code></pre>
  
  <p>Does anyone know how i can mock this property?</p>