-
Notifications
You must be signed in to change notification settings - Fork 255
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
Query model for received calls #18
Comments
Is this something you were thinking of? Something like _engine.ReceivedCalls(x => x.Rev()) which returns IEnumerable ? I'm planning on using the IsSatisfiedBy(ICall) method in ICallSpecification inside the CallRouter. What do you think? I just need to figure out what would be the best way of creating a CallSpecification object from an expression tree. The MethodInfo was easy but now I need to create the ArgumentSpecifications from the arguments. |
Added more stuff to my branch: https://github.com/Saulis/NSubstitute/tree/QueryModel I extended the CallSpecFactory to create specifications from a expression tree, which turned out to be much simpler than I originally thought. It currently supports only expressions with constant and method call parameters. With method call parameters I had to actually compile and invoke the methods in order to get the value evaluated. object result = InvokeMethod(methodCall); var argumentSpecifications = _context.DequeueAllArgumentSpecifications(); if (argumentSpecifications.Any()) { yield return argumentSpecifications.Single(); } else { yield return new ArgumentSpecification(result.GetType(), new EqualsArgumentMatcher(result)); } Comments? Anything I'm missing here? |
Basis for queries implemented in v1.5. Currently only used for |
Adding this as a placeholder for the feature while it is being planned.
Rather than expanding the API to support things like "received 4 times", it might be better to encapsulate that in a nice query model. Currently have ReceivedCalls() : IEnumerable as a starting point, but will need to add some convenience methods for selecting calls to particular members (probably using lambdas/expressions).
The text was updated successfully, but these errors were encountered: