Pregunta

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?

¿Fue útil?

Solución

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

Otros consejos

There is built-in support for that, it's called private accessors. Read about here for example: http://msdn.microsoft.com/en-us/library/bb385974%28v=vs.100%29.aspx

By the way, please consider whether you really want to unit test the internals of a project. According to some schools, you shouldn't do that, but I understand that it can be useful.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top