I'm testing a service that interfaces with a third-party system. The method exposed by the API returns objects that look something like this:
public class Thing
{
public string Name { get {...} }
public string Description { get {...} }
public Thing(string someUri)
{
/* Do some secret internal stuff and
populate all my properties. */
}
}
I need to mock these properties in order to test that my service behaves correctly according to the objects returned.
The objects are instances of a concrete class that does not implement any interfaces that I can mock. The backing fields of these properties are set in the constructor of Thing
, which takes a URI, goes off and fetches the object in some tightly-coupled third-party system and presumably sets the backing fields directly.
All of this means that I have no way to mock the properties - I can't set them directly, I can't mock an interface and I can't mock out the constructor dependencies and set the properties that way (which would diminish the usefulness of my tests anyway).
Is there any way around this?