You can grant an external (e.g. unit test) assembly access to internal members by doing the following:
- Give your test assembly a strong name (via Project Properties, Signing, Sign the assembly)
- Compile the assembly (eg. My.Test.dll)
- Open the Visual Studio command prompt
- Navigate to the folder where My.Test.dll got built
- Run: sn -Tp My.Test.dll
- This will display the full public key for the signed assembly. Copy it. (it'll be about 320 chars)
- Open the AssemblyInfo.cs file for the assembly containing the code with internals to be tested.
- Enter a line such as: [assembly: InternalsVisibleTo("My.Test, PublicKey=1234")] where 1234 is the full key generated in step 6.