private method with out args

4 posts, 0 answers
  1. Maha
    Maha avatar
    1 posts
    Member since:
    Dec 2012

    Posted 05 Dec 2012 Link to this post

    Hello Telerik Team
    I use Just Mock  and i want to mock a private method with 2 out arguments
    how to achieve it
    for example

    private void myMethod(string x, string y, out bool isFound, out string result)

  2. Ricky
    Ricky avatar
    467 posts

    Posted 06 Dec 2012 Link to this post

    Hi Maha,

    Thanks again for contacting us.

    Unfortunately, we don't support mocking of out/ref arguments for non-public method. However, we are working on this and planning to include it in one of our recent builds.

    Kind Regards
    the Telerik team

    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  3. Arthur
    Arthur avatar
    2 posts
    Member since:
    Jun 2011

    Posted 06 May 2015 in reply to Ricky Link to this post

    Wanted to find out if mocking a private method with ref/out params is now possible with JM?  




  4. Stefan
    Stefan avatar
    198 posts

    Posted 07 May 2015 Link to this post

    Hello Arthur,

    Yes, it is possible and has been for quite some time now, using the Mock.NonPublic API.

    Say you have a ref/out argument of type int. You can use ArgExpr.Ref(ArgExpr.IsAny<int>()) if you want to match the incoming value, or ArgExpr.Out(123), if you want calls to the arranged method to set the ref/out parameter to 123 on exit.


    See What's Next in App Development. Register for TelerikNEXT.

Back to Top