Reputation: 68127
Is it possible to create a stub that implements HttpContent.ReadAsAsync<T> with the help of Microsoft Fakes (in Visual Studio 2012)? If so, how?
Upvotes: 2
Views: 1407
Reputation: 1312
For the sake of future searches...
Stubs can only override methods for their own instance. You can stub any type which exposes members that can be overridden, be it abstract, interface, or a class.
In this case, you could use a shim:
ShimHttpContent.ReadAsAsyncOf1<TypeYouWant> = *something matching the method signature*
The added advantage this offers is that you can now specify the behavior per type. This is one of the most valid reasons for using shims.
Upvotes: 0
Reputation: 264
HttpContent.ReadAsAsync<T>
cannot be stubbed in VS2012. Reason being that this is not a virtual
method but an extension method. Only virtual
interface/class method can be stubbed.
Upvotes: 4