I am using Moq for my unit tests. I have this interface:
public interface IMyInterface
{
Task<AClass> MyMethod(int arg1, string arg2=0, int arg3=1, bool arg4=false);
}
In my unit test code, I have
var mockInterface = new Mock<IMyInterface>();
mockInterface.Setup(w => w.MyMethod(It.IsAny<int>(), It.IsAny<string>(),
It.IsAny<int>(), It.IsAny<bool>()))
My unit test code compiles, but when I run it, I get an exception saying
System.AggregateException: One or more errors occurred. ---> System.Reflection.TargetParameterCountException: Parameter count mismatch.
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at Moq.Extensions.InvokePreserveStack(Delegate del, Object[] args)
at Moq.MethodCallReturn`2.Execute(ICallContext call)
at Moq.Interceptor.Intercept(ICallContext invocation)
I have checked that the argument count does match, but i am not sure why I am getting this exception.
Thank you.