Reputation: 46591
I have been looking at examples of mocking using Moq and Rhino Mocks and all the examples seem to mock interfaces. Why is this? I have heard they can mock static classes, but what about non-static classes?
Upvotes: 2
Views: 199
Reputation: 36649
Because:
Upvotes: 3
Reputation: 7262
Because that was limitation of DynamicProxy (used to create instance of the mock object). Will be no problem if you using interface, but If you want to use class then you should make all public member virtual. http://tiredblogger.wordpress.com/2008/05/06/moq-mocks-use-virtual-method-or-interfaces/
Upvotes: 1