Articles - Page 3 of 6 - Hosting.Work

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

Updated on: January 7, 2024

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 it's dependencies. Moq is very useful when testing a controller that is doing database interactions through EF Core. These interactions can be Creating, Deleting, Updating or Reading of 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.


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

Updated on: December 25, 2023

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.


Onion Architecture in ASP.NET Core with CQRS : Detailed & Illustrated

Updated on: December 18, 2023

Computer Engineer Jeffrey Palermo created Onion Architecture for creating app which are highly maintainable and loosely coupled. This architecture somewhat resembles the layers which can be seen on cutting an onion vegetable. You can separate the layers of onion very easily and eat them in your salads. In the same way the layers of Onion Architecture are separatable as they are loosely coupled, and this gives a highly testable architecture.