title: Integration testing ASP.NET Web API 2 using HttpServer/HttpClient; no HttpContext
body: <p>I'm looking to integration test a web service built on ASP.NET Web API 2.  Many things such as cookies, getting the current principal, etc. are done through HttpContext.Current.</p>
  
  <p>I found the following resource on integration testing ASP.NET:
  <a href="http://amy.palamounta.in/blog/2013/08/04/integration-testing-for-asp-dot-net-web-api/" rel="nofollow">http://amy.palamounta.in/blog/2013/08/04/integration-testing-for-asp-dot-net-web-api/</a></p>
  
  <p>This works great.  It spins up an in-memory host and combined with the automated schema generation of Entity Framework 6, setup and teardown are easy.</p>
  
  <p>The problem comes in when things try and use HttpContext.Current to, as aforementioned, get cookies/etc.  It seems that when hosting in-memory using HttpServer, HttpContext.Current is always null.  This does make a little sense given there's no real request, but is a pain - it means the integration tests can't cover anything requiring anything from this property.</p>
  
  <p>What can I do here?  It looks like very little of the data I'm using is present anywhere but HttpContext.Current, so am I just going to have to spin up full external instances on IIS?</p>