What I've learned so far about REST with Yahoo Services
Well - I finally finished my Yahoo Services sample. After I poked around on their site a bit more I found their search SDK. I have to say I think mine is better of course :-). I didn't put the Asynchronous Programming Model in the code after all. I figure if you really want to do it, you can always call HttpWebRequest/Response on your own.
I did put a set of unit tests in there. After much pain in trying to get the unit tests to work against a mock service instead of the real thing I finally gave up. The classes in System.Net are just not well suited to this. You can't create most of them, and very few of them are based on an interface. This means in order to use them with mocks you have to create wrappers and factories for everything. I did finally get it to work but the result was serious code bloat. I could have reinvented System.Net by the time I finished.
It does show how important it is to factor your interfaces and classes so that they are more testable. Anything that touches an external resource (file, network, etc.) should be mockable. That means you create an interface and then implement it in your class. Allow the test to supply an implementation of the thing so it can work against mock data.
Of course, I have only just begun exploring REST. Next up, I want to understand the security model. Different sites have different models but I'll see what I can do with what they provide me.
Oh yeah - here is the Yahoo.Services sample. And Yahoo... if you want this code... well let's just say the offer is on the table :-)
Comments
Anonymous
March 11, 2008
PingBack from http://msdnrss.thecoderblogs.com/2008/03/11/what-ive-learned-so-far-about-rest-with-yahoo-services/Anonymous
March 11, 2008
Have you tried TypeMock, it doesn't require interfaces, I much prefer it.Anonymous
March 12, 2008
yeah, i was going to ask what mock framework are you using? I would use TypeMock for conventionally unmockable interactions, otherwise i stick to rhinomocks