Skip to content
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

Invocations of methods named add_X or remove_X are not recorded #487

Closed
stakx opened this issue Oct 16, 2017 · 0 comments
Closed

Invocations of methods named add_X or remove_X are not recorded #487

stakx opened this issue Oct 16, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@stakx
Copy link
Contributor

stakx commented Oct 16, 2017

public interface IHaveMethodsNamedLikeEventAccessors
{
    void add_Something();
    void remove_Something();
}

[Fact] // fails
public void CanVerifyInvocationOfMethodNamedLikeEventAddAccessor()
{
    var mock = new Mock<IHaveMethodsNamedLikeEventAccessors>();
    mock.Object.add_Something();
    mock.Verify(m => m.add_Something(), Times.Once);
}

[Fact] // fails
public void CanVerifyInvocationOfMethodNamedLikeEventRemoveAccessor()
{
    var mock = new Mock<IHaveMethodsNamedLikeEventAccessors>();
    mock.Object.remove_Something();
    mock.Verify(m => m.remove_Something(), Times.Once);
}

Both verifications fail with Moq claiming that the methods were not called; for example:

Moq.MockException:
Expected invocation on the mock once, but was 0 times: m => m.add_Something()

Configured setups:
m => m.add_Something()
No invocations performed.

@stakx stakx added the bug label Oct 16, 2017
@stakx stakx added this to the v4.8.0 milestone Oct 16, 2017
@stakx stakx self-assigned this Oct 16, 2017
@stakx stakx closed this as completed Oct 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant