Moq mock method with out specifying input parameter

You can use It.IsAny<T>() to match any value:

mockInvoice.Setup(x => x.IsInFinancialYear(It.IsAny<FinancialYearLookup>())).Returns(true);

See the Matching Arguments section of the quick start.


Try using It.IsAny<FinancialYearLookup>() to accept any argument:

mockInvoice.Setup(x => x.IsInFinancialYear(It.IsAny<FinancialYearLookup>())).Returns(true);

You can try the following:

https://7pass.wordpress.com/2014/05/20/moq-setup-and-ignore-all-arguments/

Allows:

mock
.SetupIgnoreArgs(x => x.Method(null, null, null)
.Return(value);

Tags:

C#

Mocking

Moq