0

I'm currently using HttpClient in my constructor, but using interfaces seems to be a best-practice. Since an interface for HttpClient doesn't exist (IHttpClient), I'm wondering, how can I implement an interface for HTTPClient (for unittesting purposes)?

Camilo Terevinto
  • 31,141
  • 6
  • 88
  • 120
Val
  • 103
  • 2
  • 7
  • Any code? Anything you tried? – Ermiya Eskandary Oct 11 '21 at 17:43
  • Unfortunately, it's a bit more convoluted than that. The "normal" way to do this is to create a dummy HttpClient and a class that inherits from `DelegatingHandler` and on its `SendAsync`, it doesn't actually send the request. There's some tutorials about this online – Camilo Terevinto Oct 11 '21 at 17:43

0 Answers0