I’m looking for a way to return stubbed responses when using IServiceClient.
There already exists a MockRestGateway which implements IRestGateway, but I’ve found nothing similar for IServiceClient.
I see there is already a ResultsFilter that can be set on ServiceClientBase, but it seems the intention is that this is used for caching rather than stubbing.
I’m just wondering if a MockServiceClient would be helpful or I’m missing something.
Yeah you’d use something like MockRestGateway, there’s not one for the complete IServiceClient API. I generally don’t mock Service Clients for my own Services myself. Although I’m more likely to mock 3rd Party API’s since they can be slow/unreliable. MockRestGateway was actually built for Stripe Gateway.
Although you could also use the ResultsFilter/ResultsFilterResponse delegates, they were built to support a client caching strategy, but stubbing/caching serves a similar role and this would let you use a dictionary collection for returning predictable responses which has the added benefit that when you want to test against the real service you can just comment out the ResultsFilter delegates.