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 want to fake an output of a public static method.

i.e.

Isolate.WhenCalled(() => DummyClass(param1, out param2)).WithExactArguments().DoInstead(

c =>

{

   var param1 = c.Parameters[1] as string

   param1 = "fake output";

   return false;

});

However, the param2 don't get the "fake ouput" value in the above code. Is there anything we can do ?
asked by cscmh99 (6.1k points)

1 Answer

+1 vote
public void Out_Param_Example()
{
    //Arrrange
    int val = 5;
    Isolate.WhenCalled(() => DummyClass.DummyMethod(0, out val)).WillReturn(false);

    //Act
    int returnedVal;
    var result = DummyClass.DummyMethod(0, out returnedVal);

    //Assert
    Assert.AreEqual(val, returnedVal);
}

You can find more examples in our documentation

answered by alex (17k points)
...