title: why we need to register IHttpClientFactory?
body: <p>This is the document <a href="https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/fundamentals/http-requests?view=aspnetcore-3.1</a> 
   we can see that IHttpClientFactory is registered :</p>
  
  <pre><code>services.AddHttpClient();
  </code></pre>
  
  <p>and the model class that consume it as:</p>
  
  <pre><code>public BasicUsageModel(IHttpClientFactory clientFactory)
  {
     _clientFactory = clientFactory;
  }
  
  public async Task OnGet()
  {
     ...
     var client = _clientFactory.CreateClient();
     var response = await client.SendAsync(request);
     ...
  }
  </code></pre>
  
  <p>but how about we don't register it, and we just create a new instance of it as:</p>
  
  <pre><code>public async Task OnGet()
  {
     ...
     var client = new HttpClient();
     var response = await client.SendAsync(request);
     ...
  }
  </code></pre>
  
  <p>so that the <code>BasicUsageModel</code>'s constructor doesn't need to take any argument, and when do unit testing , I don't need to use Moq to mock it, isn't that ever better?</p>
  
  <p>and for the first case, how can I mock the <code>IHttpClientFactory</code> to test <code>OnGet()</code> without actually send a request?</p>