mercredi 1 juillet 2015

Mocking HttpWebResponse with Rhino Mock

I'm just starting out with mocking and have opted for Rhino Mock. I have a method which includes two methods that I want to mock out.

They are basically calls to methods which will return an HttpWebResponse. As I'm keen to do unit testing I want to drop my dependency to the external site that these methods normally talk to. Instead I want to create a fake response based on my own conditions e.g. Status codes 200, 404, 500 etc.

I've tried looking around but I've only seen old examples or what seem like very convoluted workarounds to mock an HttpWebResponse. It's for this reason I wanted to post the question in the hope that under the latest Rhino Mock release there is a slicker, shorter and easier solution.

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire