Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要为使用静态依赖项的类编写一个测试,DllImport并强制进入static public extern .... 除了围绕静态外部依赖编写包装器之外,我还能做任何重构以使其可测试吗?
DllImport
static public extern ...
或者,您可以使用能够模拟静态方法的商业模拟框架,如 typemock。但在你的情况下,我倾向于同意 Justin Pihony 的观点,包装就可以了。