Sunday, June 01, 2008

Mocking templated methods with NMock2

Mocking a method like T GetSomething();

This is something that I have resorted to RinoMock to achieve in the past...
... well it turns out you can do it with NMock2 v1.0 as follows:

Expect.Once.On(a).Method("GetSomething", typeof(int)).Will(Return.Value(42));

I've tried to find this before.. and failed.. so I thought I should blog it to make it easier to find in google.

Thanks to ursenzler for commenting on http://www.fluidscape.co.nz/?q=node/82#comment-1692
Post a Comment

GitHub Projects