.NET

Unit Testing ASP.NET Web API by Mocking DbContext with NSubstitute

In the previous post, we created a simpleWeb API in 5 minutes. Now, let’s refactor the code so that it is unit testable with xUnit. The API we build previously was sourcing the data from MySQL database through DbContext. This is an external dependency that we need to replace in …