moo*_*ogs 7 .net mocking static-classes
我有一个静态类,它包含winspool中的一些本机方法:
public static class WinSpool
{
[DllImport("winspool.drv")]
public static extern int OpenPrinter(string pPrinterName, out IntPtr phPrinter, IntPtr pDefault);
...
//some more methods here
}
Run Code Online (Sandbox Code Playgroud)
我想模仿它们进行单元测试,但是找不到这种模式.(每个人都避免使用静态类吗?)
Gra*_*ton 10
是的,在单元测试和模拟领域,静态类通常是不受欢迎的.AFAIK没有开源模拟框架(如Rhino Mocks)支持静态类模拟
如果你绝对和肯定地必须模拟静态类,那么我担心你必须去Typemock,这不是免费的.
| 归档时间: |
|
| 查看次数: |
5741 次 |
| 最近记录: |