
Unit Testing Internal methods.
July 10, 2008Today I did some pair programming with Richard Banks from Readify.
When I explained to him that I use the IDE to generate these property accessors that use reflection to test internal and private methods he showed me a nicer way around it:
Basically all I had to do was [assembly: InternalsVisibleTo("Assembly Name")] to the assembly.cs file and make sure that the “Assembly Name” was pointing to the unit tests assembly name.
This worked perfectly! Thanks Richard!
P.S I should state the obvious note that this approach doesn’t work for private methods