title: How can I unit test my controller to make sure Windsor can resolve dependencies when using PerWebRequestLifestyle
body: <p>I have the following unit test in my application:</p>
  
  <pre><code>    [TestMethod]
      public void Windsor_Can_Resolve_HomeController_Dependencies()
      {
          // Setup
          WindsorContainer container = new WindsorContainer();
          container.Install(FromAssembly.Containing&lt;HomeController&gt;());
  
          // Act
          container.Kernel.Resolve(typeof(HomeController));
      }
  </code></pre>
  
  <p>The point of this is to make sure I don't have any windsor configuration issues that I won't realize until I access an action on that controller.  The problem is that all my object registrations are registered as <code>PerWebRequestLifestyle</code> so I don't get issues with my Entity Framwork Data Context being shared across web requests (which causes errors when multiple actions are run).</p>
  
  <p>However, whenever I run this unit test I get the following exception:</p>
  
  <p>System.InvalidOperationException: HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net</p>
  
  <p>How can I go about testing this scenario without changing the lifestyle of my object registration commands?</p>