unit testing - Compile error when trying to mock a generic method with Moq -
i have method i'd mock:
public interface iservicebus {     void subscribe<t>(isubscribeto<t> subscriber) t : class; }   for sake of example, t can called sometype. now, i'd mock this, so:
var mockservicebus = new mock<iservicebus>(); mockservicebus.setup(x => x.subscribe(it.isany<isubscribeto<sometype>>));   however, when try this, compile error:
error 65
type arguments method 'servicebus.iservicebus.subscribe(messaging.isubscribeto)' cannot inferred usage.
try specifying type arguments explicitly.
i'm not sure how work around error. ideas? or behavior not possible mock moq?
try (adding parentheses since it.isany<tvalue> method):
mockservicebus.setup(x => x.subscribe(it.isany<isubscribeto<sometype>>()));      
Comments
Post a Comment