In this tutorial I will show how to perform Unit Tests for Web API methods by using xUnit and Moq. I will be writing complete test method for GET, POST, PUT and DELETE methods of Web API. Make sure you read the complete tutorial so that you do not miss any part. The source codes for this tutorial can be downloaded from the link given at the bottom of this tutorial.(more…)
Moq as the name suggest is a mocking framework for .NET. It is used to create fake objects for underlying dependencies like that of an Entity Framework Core. This helps to test the interactions between the method and its dependencies. Moq is very useful when testing a controller that is doing database interactions through EF Core. These interactions can be like Inserting, Deleting, Updating or Reading or records from the database. In this tutorial I will be explaining all these stuffs to you so hold back tight and make sure you go through every part of this tutorial.(more…)
xUnit is a Free and Open Source testing package for .NET. It can be used to write Unit Testing codes for C# methods, Classes, Controller, API and others. In this tutorial I will teach how to use xUnit in writing Test Cases for an ASP.NET Core application.
The source codes of this tutorial can be downloaded from my GitHub Repository.(more…)