MSTest – Unit Test and Mock Typed HttpClientFactory

Today in this article, we will see MSTest – Unit Test and Mock Typed HttpClientFactory.

Mocking HttpClientFactory is simple and easy using MSTest. In fact, the mocking structure is exactly the same as what we learned in XUnit or NUnit.

For basic setup and other detailed steps – please visit this article.

Once done, kindly use the below code to enable unit testing and mocking as explained below,

A sample example is here for mocking typed HttpClient,

MSTest Unit Test and Mock Typed HttpClientFactory

References:



Please bookmark this page and share it with your friends. Please Subscribe to the blog to receive notifications on freshly published(2024) best practices and guidelines for software design and development.



Leave a Reply

Your email address will not be published. Required fields are marked *