I wrote a class of service that works with the C # GData YouTube API. A typical use of the API includes requests for a YouTubeRequest object that calls the YouTube web service and deserializes the response in JSON format in the form of a Feed , Video or Playlist instance that contains data in the form of quite a few C # properties.
I want to unit test this class of service. In my code, the YouTubeRequest object is an external dependency, and it needs to be mocked, but it does not implement any interface, so I had to add an abstraction layer. This layer has methods that return these types of Video and Playlist , and I'm trying to use Moq to create a layout that creates, say, a dummy instance of Video with test data, but many properties on the Video class are read-only, and these Video , Playlist objects and Feed hard to build, often requiring instances of other types from the YouTube platform.
I'm new to unit testing, but from what I've seen in Rob Conery's videos, there are just some frameworks that are not module friendly, like ASP.NET Webforms.
What should I do in this situation? Am I incorrectly abstracting a YouTubeRequest object? I understand that this added layer of abstraction should be very simple, but if I added a call to, say, a map layer, I could map the data to my own types. Mocking an interface that returns my types would be a lot easier, since I could let you get and set properties and easily create dummy data. Although the code that interacts with YouTube is relatively small, I expect that over time it will increase in size and complexity, and therefore the idea of ββabandoning unit testing is generally tedious.
anon
source share