Is a wrapper the only way to test a static dependency?

别来无恙 提交于 2019-12-10 23:19:31

问题


I need to write a test for a class that uses a static dependency via DllImport and is forced into static public extern .... Is there any refactoring I can do to make this testable beyond writing a wrapper around the static external dependency?


回答1:


Alternatively, you can use commercial mocking frameworks, like typemock, that enable mocking static methods. But in your case, I tend to agree wth Justin Pihony, that wrapping would be just fine.



来源:https://stackoverflow.com/questions/17203061/is-a-wrapper-the-only-way-to-test-a-static-dependency

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