OJ Develops

Thoughts on software development. .NET | C# | Azure

How to Test Internal Methods in Visual Studio

02 September 2013

How to Test Internal Methods in Visual Studio thumbnail

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.