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

Allow raising events on inner mocks #774

Merged
merged 4 commits into from
Mar 7, 2019

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Mar 7, 2019

Fixes #166, i.e. when mock.Raise is given an event += null expression for a sub-mock's event, then Moq will now raise the event on that sub-mock instead of on the root mock. This is achieved by the new machinery we recently added in #767 (improved expression reconstruction from delegates) and #765 (expression splitting & recursive processing).

@stakx stakx added this to the 4.11.0 milestone Mar 7, 2019
src/Moq/ExpressionExtensions.cs Outdated Show resolved Hide resolved

var expression = ExpressionReconstructor.Instance.ReconstructExpression(eventExpression);

// TODO: validate that expression is for event subscription or unsubscription
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An obvious TODO left to do.


var expression = ExpressionReconstructor.Instance.ReconstructExpression(eventExpression);

// TODO: validate that expression is for event subscription or unsubscription
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, to this TODO.

src/Moq/MethodCall.cs Outdated Show resolved Hide resolved
That is, convert these API methods to use `ExpressionReconstructor` to
turn the += expressions into `LambdaExpression`s, then use the new re-
cursive approach based on setup expression splitting.
@stakx stakx merged commit 355fb4b into devlooped:master Mar 7, 2019
@stakx stakx deleted the raise-inner-mock-events branch March 7, 2019 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant