Thank you for bringing this issue to us.
You do not need to use Mock.Replace in order to mock the "System.Drawing.Printing.PrintDocument" class. Mock.Replace is used for mocking MSCorlib members, you could read more about it here
To demonstrate you how the PrintDocument class could be faked, I made the following example class:
Now, in our test method I will check if the doc.Print() is actually been called. I`m also arranging that it should be called exactly once, like this:
var mock = Mock.Create<System.Drawing.Printing.PrintDocument>();
var newMyClassInstance =
Mock.Arrange(() => mock.Print()).DoInstead(() => isCalled =
Note that, I`m using MSTesting framework and the test is behaving as expected.
I must object that, our product is well integrated in working with MSTest runner. Still, I could also recommend you using JustCode testing framework, NUnit or TestDriven.NET.
You are always welcome to check our online help documentation
, in which you will be able to find much more information and examples concerning JustMock.
I hope this answers your questions. Just ask, if there is anything else I could help you with.
the Telerik team
Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums
, or our JustTrace