title: Creating a System.Web.Caching.Cache object in a unit test
body: <p>I'm trying to implement a unit test for a function in a project that doesn't have unit tests and this function requires a System.Web.Caching.Cache object as a parameter. I've been trying to create this object by using code such as...</p>
  
  <pre><code>System.Web.Caching.Cache cache = new System.Web.Caching.Cache();
  cache.Add(...);
  </code></pre>
  
  <p>...and then passing the 'cache' in as a parameter but the Add() function is causing a NullReferenceException. My best guess so far is that I can't create this cache object in a unit test and need to retrieve it from the HttpContext.Current.Cache which I obviously don't have access to in a unit test.</p>
  
  <p>How do you unit test a function that requires a System.Web.Caching.Cache object as a parameter?</p>