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

Expose Mock.Setups, part 4: Mock, fluent setup & inner mock discovery #989

Merged
merged 4 commits into from
Apr 2, 2020

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Apr 2, 2020

(This is a follow-up to #987.)

This adds one new property and two new methods to ISetup:

  • Mock Mock { get; } to find the mock to which a setup belongs;

  • bool? ReturnsMock(out Mock innerMock) to get at a setup's inner mock (e.g. when doing recursive verification);

  • bool IsPartOfFluentSetup(out IFluentSetup fluentSetup) to get at the original "fluent" setup expression for those setups that have been split apart into many setups on several mocks.

This will very likely conclude this series of PRs.

...to get at a setup that more closely matches the original "fluent"
setup expression that one would find in user code.

The term "fluent" may be slightly inaccurate here: "fluent" usually
applies in cases where a method returns the *same* instance for method
chaining. While fluent setup expressions do feature method chaining,
each method typically acts on a *different* mock object.

Let's use that term nevertheless, since it's the one historically used
inside Moq's code base and documentation.
@stakx stakx added this to the 4.14.0 milestone Apr 2, 2020
src/Moq/FluentSetup.cs Show resolved Hide resolved
src/Moq/IFluentSetup.cs Show resolved Hide resolved
src/Moq/Mock.cs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant