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
Hi, I achieved to fake ref and out values of a private method using Reflective Mocks. I want to learn if it is possible by using the Arrange Act Assert API or not?
asked by mkg (4.3k points)

2 Answers

0 votes
Hi,
You can use the DoInstead API to do that.
DoInstead lets you define your own callback that Isolator will call when the faked method gets called. Inside the callback you have an access to the method arguments and you can check them or modify them.

Here is an example:
public class Foo
{
    private void Bar(out int x)
    {
        x = 1;
    }
}

// Test code

var fake = new Foo();
Isolate.NonPublic.WhenCalled(fake, "Bar").DoInstead(context =>
                                                        {                             
                                                            context.Parameters[0] = 5;
                                                        });


Please let me know if it helps.
answered by ohad (35.4k points)
0 votes
That helped alot.
Thanx.
answered by mkg (4.3k points)
...