chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
Welcome to Typemock Community! Here you can ask and receive answers from other community members. If you liked or disliked an answer or thread: react with an up- or downvote.
0 votes
First great pice of work! I'm working with it for a 2 days now and its still amazing how easy it is to setup test. And this whitout any test code in my production code.

I have a question is it posible to create and use a Custom Argument Check for Ref/out parameter???

In other words I want to check a few field of an object that is send (as a ref param) to the mock and then "return" (it a ref) a predifiend state object.

If not is it an easy implementation so maybe a new feature? :idea:


Sybren
asked by (680 points)

3 Answers

0 votes
I found it already. sorry for this topic

from the topic "argument constrains":
2. Use the DynamicReturnValues (it can be used for void methods too)
Code:
mock.ExpectAndReturn("DoSomething",new DymanicReturnValue(Method));

In the Method we can perform our checks and change ref and out values.
answered by (680 points)
0 votes
Hi,

There is an even simpler way:

suppose we have the following method:
void MyMethod(ref int arg)


we want to mock arg to output 10 and our custom checker is called Check

Here is the code.
myMock.ExpectCall("MyMethod").Args(
  // set arg to 10
new Assign(10).AndCheck(
  // invoke custom checker
  new ParameterCheckerEx(Check)));
answered by (3.9k points)
0 votes
Thanks i have it working now.

(But to bad it is a enterprice feature.)
answered by (680 points)
...