I have a static class that wraps some native methods from winspool:
public static class WinSpool
{
[DllImport("winspool.drv")]
public static extern int OpenPrinter(string pPrinterName, out IntPtr phPrinter, IntPtr pDefault);
...
//some more methods here
}
I would like to mock them for unit testing, but couldn't find a pattern for this. (Does everyone avoid static classes?)
Yes, static class is generally frowned upon in the field of unit testing and mocking. AFAIK no open source mocking framework ( such as Rhino Mocks) support static class mocking
If you absolutely and positively must mock static class, then I afraid that you must go for Typemock, which is not free.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With