When setting up a Moq object to return a specific value regardless of input parameters I currently have to effectively write out the full signature, e.g.
Mock.Get(myThing).Setup(x => x.DoThing(It.IsAny<Int32>(), It.IsAny<String>(), It.IsAny<IEnumerable<Boolean>>())).Returns(false)
This is a little tedious if there are multiple input parameters and I don't care about any of them, so is there a way that I can say It.IsAnyForAllInputParameters()?
As specified in the comment by Bernhard Hiller, if this would be possible, then the moq should know how to setup all the methods with the same name. This should not be a problem, unless they have different return types:
void Sum(int a, int b, ref int result)
{
result = a + b;
}
int Sum(int a, int b)
{
return a + b;
}
Then if you want to Setup Sum
method to return value 10, how should the moq proceed for the first Sum
method?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With