Search code examples
c#visual-studiounit-testingaccess-levels

Protection Levels and Visual Studio unit tests with C#


I am setting up some unit tests for a C# project I'm working on, and I opted to use Visual Studio's built-in unit test project. The problem is that I have been giving most of my classes in the project the default, internal access level. Now they can't be reached by my unit test project because it is a different assembly.

It would be trivial to just make all my classes in the project public so that the unit test project can access them, but isn't it idiomatic to keep classes which are only used internally by a project internal?


Solution

  • you can make your internals visible to the test project - see here for more info