Tuesday, August 14, 2007

Testing Private methods w Nunit

Sometimes we run into the problem of testing private methods that are not visible from a Nunit assembly. One way that could be accomplished, without breaking the data encapsulation is to make the method in questions internal and add the following two lines to your code:


using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("PutYourTestAssemblyNameHere")]

now it will work

No comments: