Hello,
I discovered a bug, while trying to mock a function with a out-parameter. All works fine as long as no parameter-verification is done, but once RecordExpectations.CheckArguments([..]) is used, the out-parameter will only return null.
Steps to reproduce:
1. Take the example found in your documentation (
https://www.typemock.com/Docs/UserGuide/ ... ndOut.html) and slightly modify it, so that it actually compiles (and shows the bug). The result will look as follows:
public class ToBeTested
{
// C#
// An example method with ref and out parameters
public static int SomeMethod(ref string name, out int[] list)
{
// Do Something
list = new int[1];
return 0;
}
}
[Test]
public void RefReturnValues()
{
string returnNameValue = "TypeMock"; // we will return for ref parameter
int[] returnListValue = new int[5]; // we will return for out parameter
using (RecordExpectations recorder = new RecordExpectations())
{
// CAUTION: ALL calls here are mocked!!!
ToBeTested.SomeMethod(ref returnNameValue, out returnListValue);
recorder.CheckArguments(Check.IsAny(), Check.IsAny());
recorder.Return(3);
}
// mock returns 3, sets name to "TypeMock" and list to a 5 element array
// so this test will pass
string name = "";
int[] list;
Assert.AreEqual(3,ToBeTested.SomeMethod(ref name, out list));
Assert.AreEqual("TypeMock",name);
Assert.AreEqual(5,list.Length);
MockManager.Verify();
}
2. Run the test
Expected results:
-> The test should perform fine
Actual results:
-> The test fails, as name is still "" and list is still null!
Workaround (not really):
-> Remove the following line: recorder.CheckArguments(Check.IsAny(), Check.IsAny());