title: How to mock the CreateResponse<T> extension method on HttpRequestMessage
body: <p>I'm using ASP.Net MVC 4 RC's ApiController and I'm trying to unit test a GET method.</p>
  
  <p>This method uses the <code>CreateResponse&lt;T&gt;</code> method that's on the <code>HttpRequestMessage</code>, but I've no idea how to mock this or to make it function correctly. </p>
  
  <p>The method's body contains this:</p>
  
  <pre><code>MediaTypeHeaderValue header = new MediaTypeHeaderValue(versionedSmartBlock.ContentType);
  var response = Request.CreateResponse&lt;SmartBlock&gt;(
      HttpStatusCode.OK, versionedSmartBlock, header);
  </code></pre>
  
  <p>Within my unit test, I create an empty <code>HttpRequestMessage</code>:</p>
  
  <pre><code>CallsController api = new CallsController(
      managerMock.Object, config, adapterFactoryMock.Object);
  api.Request = new HttpRequestMessage(
      HttpMethod.Get, "http://localhost/Initiate?ern=%2B44123456789");    
  var response = api.Get("+44123456789", null);
  </code></pre>
  
  <p>But it just generates an <code>InvalidOperationException</code>:</p>
  
  <blockquote>
    <p>The request does not have an associated configuration object or the
    provided configuration was null.</p>
  </blockquote>
  
  <p>Has anyone got any pointers on how I can configure the <code>HttpRequestMessage</code> so that the <code>CreateResponse</code> method actually does its job?</p>