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

Refactor SetupCollection towards a smaller & more consistent set of methods #1201

Merged
merged 7 commits into from
Aug 19, 2021

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Aug 19, 2021

No description provided.

By accepting a `Setup` predicate instead of an `Invocation`, the method
becomes more generally useful.

Adding `Last` to the name clarifies that the collection will be searched
in reverse order. This needs to be clarified because some methods
process the collection in forward order, while others do the opposite.

The name change also makes `SetupCollection` more similar to regular
.NET collections (see e.g. `List<>.FindLast`).
The name change makes `SetupCollection` more similar to regular .NET
collections (see e.g. `List<>.FindAll`).

The method now also filters out overridden setups by default, just like
`FindLast`. The new name is thus a hint that both methods work in a
similar fashion.
This was only used in `HandleWellKnownMethods` to check for the presence
of setups for `object` methods. `FindAndExecuteMatchingSetup` is looking
for setups using `FindLast`; do it the same way here.
This makes the `TryFind` extension methods more uniform.
The new method ought to be more efficient, too, since only one active,
non-conditional setup can ever match an invocation or invocation shape;
so it is sufficient to consider only that setup's inner mock, instead of
fetching all inner mock setups beforehand.
@stakx stakx merged commit a7632bf into devlooped:main Aug 19, 2021
@stakx stakx deleted the refactor/setup-collection branch August 19, 2021 19:28
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