How to print on a null printer in .NET?

I need to write unit test for a method that will print a document. Is there an easy way to send output to the Windows / dev / null equivalent? I assume that if our assembly server prints a document at each check, it will quickly go up in price .;)

Ideally, this will work both on our build server (which does not have a default printer) and on our development machines (which do), so I would prefer not to change the default printer.

Thanks for all the great answers that will surely follow this fascinating question.

+3
source share
2 answers

, .

TypeMock RhinoMocks , .

TypeMock:

Mock mock = MockManager.Mock<PrintManager>();
mock.ExpectCall("Print");

, . , , unit test - . ​​

+1

, Windows, NUL. , Windows: NUL "Generic" "Generic/Text Only".

+13
source

All Articles