Articles - Page 2 of 5 - Hosting.Work


Unit Testing of Web API with xUnit and Moq

Updated on: August 18, 2021

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…)

How to use Moq and xUnit for Unit Testing Controllers in ASP.NET Core

Updated on: August 18, 2021

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…)

How to perform Unit Testing with xUnit in ASP.NET Core

Updated on: August 18, 2021

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…)