问题
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