There are various ways to test a Class member which is not public
- By making the private members public of a class under test
- Breaks the encapsulation principle
- API is modified just for the sake of testing
- Breaks the encapsulation principle
- API is modified just for the sake of testing
- Breaks the encapsulation principle
- API is modified just for the sake of testing
- PrivateObject to access non public Instance members of a class under test
- PrivateType to access static members of a class under test
These classes are inside Microsoft.VisualStudio.TestTools.UnitTesting namespace. I have created code snippets in Visual Studio 2010.CodeProject
Read more: Daily .NET tips