Testing Internal Methods in C#

October 16, 2018

When you have a C# project that contains methods marked internal, they can be tested from a separate Tests project.

In the project to be tested, open up Properties/AssemblyInfo.cs and add

[assembly: InternalsVisibleTo("ViewerTests")]

where ViewerTests is the name of the project that contains the tests.

This ViewerTests project will now be able to refer to internal methods.

References