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 5: Simplify fluent setup & inner mock discovery #995

Merged
merged 5 commits into from
Apr 14, 2020

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Apr 14, 2020

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

This makes the following main changes:

  • bool? ISetup.ReturnsMock(out Mock innerMock)
    Mock ISetup.InnerMock { get; }
  • bool ISetup.IsPartOfFluentSetup(out IFluentSetup fluentSetup)
    ISetup ISetup.OriginalSetup { get; }
  • bool IInvocation.WasMatched(out ISetup matchingSetup)
    ISetup IInvocation.MatchingSetup { get; }

(While methods with out parameters are used extensively in Moq's code base, they are probably less suited for a good public API, not least because such members don't play nice with e.g. Visual Studio's Watch window—for users wanting to quickly inspect a mock's setups.)

We're not even using the `bool? ReturnsMock` method internally--instead
we have a `bool ReturnsInnerMock` wrapper method. That might be a good
sign that the 3VL is too clunky for practical use. Let's simplify even
if the resulting method will be a little less precise.
@stakx stakx added this to the 4.14.0 milestone Apr 14, 2020
@stakx stakx force-pushed the mock-setups-5 branch 2 times, most recently from 2c9097a to 9cc6221 Compare April 14, 2020 19:40
 1. `ISetup` is mostly about introspection; methods with `out` params
     aren't suited well to e.g. inspection in an IDE's Watch window.

 2. What if we later want to add an `ISetup` sub-type representing all
    setups created by `SetupAllProperties`? We'd have to add another
    method with the same overall purpose. `OriginalSetup` OTOH is more
    general and could more easily cover such a scenario.
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