I am setting up Moq like:
mockCommand.Setup(foo => foo.Post<Foo, Response>(It.IsAny<Foo>()))
.Returns((Foo m) =>
{
if (m . . . .)
{
return new <Response>()
{
<...>
};
}
else
{
return new <Response>()
{
<...>
};
}
});
But I get an exception:
System.ArgumentException : Invalid callback. Setup on method with 2 parameter(s) cannot invoke callback with different number of parameters (1).
The generic method is defined as:
TResponse Post<TRequest, TResponse>(TRequest request, params string[] query)
The only thing that I can think of is that somehow because I am conditionally returning response it is somehow confusing Moq so it throws the exception. Ideas?