How to Test Internal Methods in Visual Studio

Today I will show a very simple way on how to test internal methods in Visual Studio.

Let's say the internal methods to be tested are in an assembly named "MyApp", and the tests are located in an assembly named "MyApp.Tests". For the MyApp methods to be visible to the tests assembly, insert the following line in the AssemblyInfo file of MyApp:


[assembly: InternalsVisibleTo("MyApp.Tests")]

With just this line of code, you will now be able to use and test the internal methods.

Popular posts from this blog

Vertical Slices Application Design with MediatR: Part 2

Deploying a Web Application to Local IIS using Visual Studio 2017

Login with AngularJS and ASP.NET Web API