Mocking method with out parameter only sets the out parameter once

0 votes

I recently moved from TypeMock 6.0.8 to, and I've run into a behavior difference that causing tests to fail.  I have many tests that mock methods with out parameters.  They set the out parameter by establishing the expected value in the Isolate call:

string theValueIWantClientsToGet = "thisValue";
Isolate.WhenCalled(() => someMock.TryGet(out theValueIWantClientsToGet)).WillReturn(true);

The first call to TryGet will set the out parameter as I expect.  The second call on ends up setting the out parameter to null.

I can work around this issue by changing to:

string theValueIWantClientsToGet = "thisValue";
Isolate.WhenCalled(() => someMock.TryGet(out theValueIWantClientsToGet)).DoInstead(
    context =>
        context.Parameters[0] = theValueIWantClientsToGet;
        return true;

While this does resolve the issue, as a company we have thousands of existing tests, and we'd rather not have to #1 find all these cases and #2 modify test code that used to work.



asked Apr 8, 2016 by kevinms99 (1,140 points)

1 Answer

0 votes
It reproduces so I can confirm that this is bug.

I'll update here on the status.


Alex Galin | Support Team

answered Apr 11, 2016 by alex (17,890 points)