Skip to content

Latest commit

 

History

History

README.md

UnitTestSimpleSystem - Unit Testing Fundamentals with xUnit and Moq in C#

YouTube Blog Newsletter All Links LinkedIn

Educational project demonstrating unit testing fundamentals in C# using xUnit and Moq. Features a ConsoleCalculator class that depends on an IConsole abstraction rather than calling Console.WriteLine directly, enabling testability through dependency injection. The test project uses Moq with strict behavior to verify both return values and side effects.

Built on .NET Framework 4.6, this project demonstrates the Arrange-Act-Assert pattern, mock setup/verification, and how abstracting dependencies enables isolated unit testing. By injecting an IConsole interface, the calculator's logic can be tested without any console I/O, making the tests fast, deterministic, and reliable.

Getting Started

Prerequisites

  • .NET Framework 4.6
  • Visual Studio

Running the Project

Open the solution in Visual Studio, build, then run tests via Test Explorer or dotnet test.

Related Resources

Newsletter

If you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:

Subscribe to Dev Leader Weekly

Connect with Dev Leader


BrandGhost

Powered by BrandGhost 👻