Coder Social home page Coder Social logo

Comments (3)

Saulis avatar Saulis commented on May 18, 2024

Is this something you were thinking of?

Saulis@5a019d6

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.

from nsubstitute.

Saulis avatar Saulis commented on May 18, 2024

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.
Invoking the argument specs adds them to the argument specs queue from which they can be then dequeued and returned.

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?

from nsubstitute.

dtchepak avatar dtchepak commented on May 18, 2024

Basis for queries implemented in v1.5. Currently only used for Received.InOrder.

from nsubstitute.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.