January 18th 2012

Internals Visible To

I was working on an HttpModule today that I will try and blog about later. I wanted to make an interface that I was programming against internal. This of course broke my unit tests. Luckily I remembered that you can make internals visible to other assemblies such as test assemblies. I just couldn’t remember how.

This stackoverflow post had the answer. The line of code below needs to be added to the assembly.cs file located in the project with the internal code.

[assembly: InternalsVisibleTo("name of assembly here")] 

Since I am using Moq for mocking, I also had to make the internals visible to the castle dynamic proxy. I found out how to do that on this post. You just have to add the line below:

   [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]