-
Notifications
You must be signed in to change notification settings - Fork 269
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 chaining a callback method before the Returns call. #98
Comments
Thanks a lot for the suggestion. I think I'd prefer chaining it off I don't mind the code block, but I don't think it would do any harm having
I'll spike it out and see how it goes. Is it something you need often enough to make it worth expanding the surface area of the API? The code block does have a bit more punctuation noise, but it also has the benefit of not needing to learn more API or read any more docs. |
Chaining it off It does come up quite often for me in async scenarios. Also, it'd make it easier to port code written in other mock frameworks over. One nice thing about making In fact, you could write this new method as an extension method and hide it in an "Advanced" (or somesuch) namespace so you're main API isn't cluttered. |
I've been spiking this out and wanted to get some opinions on how this should work with the idea of ignoring args:
Should the initial call specification (i.e. |
Hmm, I thought you were going to chain this off of |
@haacked, yes, but after discussing it with @AnthonyEgerton we thought |
Cool! In that case I assume that you could just have |
I've pushed up a first go at this feature @04b0786f70f11a84e385955e80404996a5ece3ac. Currently it works like this:
Arguments to the call are accessible from At the moment I've used I'd like to experiment with it a bit more before pushing out a release, so please share any feedback you have while it's still easy to tweak the feature without introducing breaking changes. :) |
Cool. I liked |
Released in v1.6.0. |
Suppose I have the following interface.
I love the current syntax for setting up a return value. So simple.
But if I need to also run a callback, my tight clean code gets a bit ugly. Not too ugly, but ugly. I can no longer use a simple lambda, I have to use a code block.
What I'd love to do instead is chain a callback before the
Returns
call.If it feels more natural, you could chain it to the end instead. But the behavior would probably be the same.
Bonus if the callback method has 2-overloads:
Action
.Action
with the same arguments as the method being substituted.Thoughts?
The text was updated successfully, but these errors were encountered: