-
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set callback on function call that uses default parameter #689
Comments
@Custodia: The following test does what you've described, and it passes just fine: public interface IFoo
{
void Do(int arg = 42);
}
[Fact]
void Callback_invoked_if_mocked_method_called_without_explicit_value_for_default_parameter()
{
bool callbackInvoked = false;
var mock = new Mock<IFoo>();
mock.Setup(m => m.Do(It.IsAny<int>())).Callback(() => callbackInvoked = true);
mock.Object.Do();
Assert.True(callbackInvoked);
} Can you post a brief failing test that demonstrates your problem? |
I'll look at this again on Monday. |
I'm actually not sure what I changed to resolve the issue but it does not indeed seem to be related to what the default parameter after all. |
Well, I'm glad to hear you got things working. 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you setup a callback on a function with a default parameter and then call the function without overriding the default parameter the callback function supplied to Moqs .Callback will never be called.
The text was updated successfully, but these errors were encountered: