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
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 (24.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.5k points)
0 votes
That helped alot.
Thanx.
answered by mkg (24.3k points)
...