title: How can you shim/fake HttpClient.GetAsync
body: <p>I have a processor that handles calling to an endpoint and returning the response. The method is shown below </p>
  
  <pre><code>public Event GetEvent()
  {
      HttpClient client = new HttpClient();
      client.BaseAddress = new Uri("https://www.test.com");
  
      HttpResponseMessage response = client.GetAsync("/event").GetAwaiter().GetResult();
  
      var content = response.Content.ReadAsStringAsync().Result;
      Event newEvent = JsonConvert.DeserializeObject&lt;Event&gt;(content);
  
      response.EnsureSuccessStatusCode();
  
      return newEvent;
  }
  </code></pre>
  
  <p>Now I need to create a unit test for this class that does not actually make the request to the endpoint. My unit test follows this pattern:</p>
  
  <pre><code> public HttpClientProcessorTest()
   {
       InstantiateClassUnderTest();
   }
  
    [Fact]
    public void HttpClientProcessor_GetEvent_EnsuresSuccessfulStatusCodeAndReturnsEvent()
    {
        ShimHttpClient.AllInstances.GetAsync = (x) =&gt;
        {
  
        };
  
        ClassUnderTest.GetEvent();
    }
  </code></pre>
  
  <p>However I get the error <code>'ShimHttpClient.AllInstances' does not contain a definition for 'GetAsync'</code>. I added System.Net.Http to the references, right-clicked and added fakes assembly, but it is only providing access to some of the methods, not <code>GetAsync()</code>. I left out the asserts because they are not needed until I can even get the shim working. </p>
  
  <p>How can I shim GetAsync()?</p>