Easy way to use TDD with internal classes

This is just a short note about a really useful assembly attribute which enables you to test classes with internal access modifiers.

I not sure if this is well known but I certainly didn’t know about it until today so I though it a good idea to post it…

Simply add the following to the AssemblyInfo.cs file:

[assembly: InternalsVisibleTo("MyTestClassAssembly")]

You will also need to add the following reference if it’s not already in the file:

using System.Runtime.CompilerServices;

Anyway, that’s all it takes… nice.

Kind Regards,

Sean McAlinden

www.asp-net-mvc.com

No Comments