Component (service) testing

Component or service testing is a method where we bypass the UI and directly test the API (in our case, the ASP.NET Core Web API). Using this test, we confirm that an individual service does not have any code bugs and that it is working fine functionality-wise.

Testing a service does not mean it is an independent service. This service might be interacting with an external service. In such a scenario, we should not call the actual service but use the mock and stub approach. The reason for this is our motto: to test code and make sure it is bug-free. In our case, we will use the moq framework for mocking our services.

There are a few things worth noting for component or service testing: