CSharp

Unit Testing Private(Protected) Methods in C#

Any developer that you speak to, will tell you the importance of unit testing, not only its a check against your logic, but it also avoids bugs and helps you to have confidence in your work that goes into production. Usually when creating private methods within a class, that private method is tested by covering the public method(s) that calls the private method. But in some cases, if you just want to write unit tests to validate that your private method is doing what it is supposed to do, then this article is for you.

Organize your DI registrations into modules when using built in DI in .NET Core

I love Microsoft.Extensions.DependencyInjection a.k.a Built in DI in .NET core. Although it lacks some of the advance configurations supported by other DI frameworks like Autofac, the reason it wins me over every time is the simplicity and its super lightweight. One of the things it lacks in basic usage scenarios is that the ability to organize your registrations in the assembly level and not exposing everything in public methods. Or maybe I’m spoilt by Ninject and Autofac.

Dependency Injection in .NET Core Console Application using IHost

All .Net core app types in have a DI starting point or anchor point i.e startup.cs except console application. Here is a short guide to setup DI in a .NET Core console app. Let’s create a simple console app and the message “Hello World” lets move to an injected class later. So initially your console App’s entry method (Main) will look like this. class Program { static void Main(string[] args) { Console.