How do I Moq a method that has an optional argument in its signature without explicitly specifying it or using an overload?
问题 Given the following interface: public interface IFoo { bool Foo(string a, bool b = false); } Attempting to mock it using Moq: var mock = new Mock<IFoo>(); mock.Setup(mock => mock.Foo(It.IsAny<string>())).Returns(false); gives the following error at compile time: An expression tree may not contain a call or invocation that uses optional arguments I\'ve found the issue above raised as an enhancement in Moq\'s list of issues and it appears to be assigned to the 4.5 release (whenever that is). My