It is possible to add default value in the interface with C#.
For the Setup() method, it is OK, but for the Callback() we must explicitly check that the optional argument exists.
public class UnitTest1
{
[Fact]
public void Test1()
{
var mock = new Mock<ISampleInterface>();
mock.Setup(m => m.TestMethodWithOptionalParam(It.IsAny<int>()))
.Callback((int a) => { }); // This compile, but Moq raise an ArgumentException, because the call back method does not contains the 'optionalParam' argument.
}
public interface ISampleInterface
{
void TestMethodWithOptionalParam(int requiredParam, int optionalParam = 42);
}
}
Fix this behavior in the PosInfoMoq2003 rule.
This is linked to the #57 issue.
It is possible to add default value in the interface with C#.
For the
Setup()method, it is OK, but for theCallback()we must explicitly check that the optional argument exists.Fix this behavior in the PosInfoMoq2003 rule.
This is linked to the #57 issue.