How to test Framework if Unit tests are in separate assembly?

不羁的心 提交于 2019-12-11 08:04:23

问题


I have assembly with my framework and assembly with tests. But I need to test internal classes or substitute some services. For example, - I need to test internal helper. - My framework read and analyze files created by other application. I create these files manually for tests. But I can't give it to my framework from separate assembly. I need to create mock for internal service to provide these files.


回答1:


If You want Your internal classes to be visible to your tests You must make your test assembly a friend of your framework assembly.

You have to add

[assembly: InternalsVisibleTo("MyTestAssembly")]

in your framework assembly.

Here is a link to MSDN Documentation about friend assemblies - http://bit.ly/FriendAssemblies



来源:https://stackoverflow.com/questions/6048495/how-to-test-framework-if-unit-tests-are-in-separate-assembly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!