title: Unable to Mock HttpClient PostAsync() in unit tests
body: <p>I am writing test cases using xUnit and Moq.</p>
  
  <p>I am trying to mock PostAsync() of HttpClient, but I get an error.</p>
  
  <p>Below is the code used for mocking:</p>
  
  <pre><code>   public TestADLS_Operations()
      {
          var mockClient = new Mock&lt;HttpClient&gt;();
          mockClient.Setup(repo =&gt; repo.PostAsync(It.IsAny&lt;string&gt;(), It.IsAny&lt;HttpContent&gt;())).Returns(() =&gt; Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK)));
  
          this._iADLS_Operations = new ADLS_Operations(mockClient.Object);
      }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Unsupported expression: repo => repo.PostAsync(It.IsAny(),
    It.IsAny()) Non-overridable members (here:
    HttpClient.PostAsync) may not be used in setup / verification
    expressions.</p>
  </blockquote>
  
  <p>Screenshot:</p>
  
  <p><a href="https://i.stack.imgur.com/wjuCb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wjuCb.png" alt="enter image description here"></a></p>