Articles - Page 2 of 5 - Hosting.Work


How to tests Entity Framework Core Codes

Updated on: August 18, 2021

xUnit can be easily used to test Entity Framework Core codes. This tutorial will tech how to test CRUD operations code created with Entity Framework Core in xUnit. I will write 8 test methods to cover each and every aspect of testing so make sure you cover this whole tutorial till the end.

(more…)

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