Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mocking classes that aren't interfaces

I've been writing some providers in c# that inherit from the providerbase class. I've found that it's hard to write tests that use the providers as most mocking frameworks will only allow you to mock an interface.

Is there any way to mock a call to a provider that inherits from providerbase?

If not, is there a pattern that I can use to implement mocking of providers?

like image 416
lomaxx Avatar asked Sep 25 '08 07:09

lomaxx


1 Answers

Mocking frameworks should be able to create for you a mock object based on a class, as long as it's got virtual members.

You may also want to take a look at Typemock

like image 117
cruizer Avatar answered Sep 20 '22 05:09

cruizer