I have a method I'd like to mock:
public interface IServiceBus
{
void Subscribe<T>(ISubscribeTo<T> subscriber) where T : class;
}
For the sake of this example, T
can be something called SomeType
.
Now, I'd like to mock this, like so:
var mockServiceBus = new Mock<IServiceBus>();
mockServiceBus.Setup(x => x.Subscribe(It.IsAny<ISubscribeTo<SomeType>>));
However, when I try this, I get this compile error:
Error 65
The type arguments for method 'ServiceBus.IServiceBus.Subscribe(Messaging.ISubscribeTo)' cannot be inferred from the usage.
Try specifying the type arguments explicitly.
I'm not sure how to work around this error. Any ideas? Or is this behavior not possible to mock with Moq?