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

Need a way to verify that code added an event handler to an event #825

Closed
hughbe opened this issue May 8, 2019 · 3 comments
Closed

Need a way to verify that code added an event handler to an event #825

hughbe opened this issue May 8, 2019 · 3 comments
Milestone

Comments

@hughbe
Copy link

hughbe commented May 8, 2019

E.g. I have the product code

IDesignerEventService service = ...;
service.ActiveDesignerChanged += handler;

I need to verify that we called +=

@stakx
Copy link
Contributor

stakx commented May 8, 2019

... and you're not the first. Someone will have to implement this feature or it's not going to happen...

See #49.

@stakx stakx added this to the 4.13.0 milestone Jul 24, 2019
@stakx
Copy link
Contributor

stakx commented Jul 24, 2019

@lepijohnny is currently working on this in #857.

stakx pushed a commit that referenced this issue Jul 24, 2019
* WIP: initial feature commit
* Thread-safe hasEventSetup check
* Fix Resources
* PR review comments processed
* CHANGELOG.md updated
* Fix codefactor violation.
@stakx
Copy link
Contributor

stakx commented Jul 24, 2019

Resolved in #857. You'll be able to use Setup[Add|Remove] and Verify[Add|Remove|All] for event subscription and unsubscription from version 4.13.0 onwards. Note that you will have to use SetupAdd or SetupRemove to enable verification of event (un)subscription. These new setup methods enable the recording of such += and -= invocations. If you never call either of these setup methods, the (un)subscription calls won't get recorded and thus won't be verifiable. This is for back-compat's sake.

Thanks @lepijohnny for having taken care of this long-standing feature request. (There have been a few issues in the past asking for this same feature.)

@stakx stakx closed this as completed Jul 24, 2019
ishimko pushed a commit to ishimko/moq4 that referenced this issue Sep 2, 2019
* WIP: initial feature commit
* Thread-safe hasEventSetup check
* Fix Resources
* PR review comments processed
* CHANGELOG.md updated
* Fix codefactor violation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants