Hi all,
I have a method that i want to mock that takes an array as a argument. In a real call, the method would modify this array and the resultant array would be use further along in code. What i tried to do was pass in array to the mocked method call, that had values that would be valid when the array is used again. However what i find is when the call is being made to the mocked method it doesn't use the array i have specfied when setting up the mock, instead using the original array, Is there a way around this problem.
e.g
public interface ITest
{
int Do(int[] values);
}
public void MyTest
{
var testMock = new Mock<ITest>();
int[] returnArray = new int[] {1,2,3};
testMock.Setup(x => x.Do(returnArray)).Returns(0);
MyTestObject obj = new MyTestObject();
obj.TestFunction(testMock.Object);
}
public class MyTestObject
{
.....
public void TestFunction(ITest value)
{
int [] array = new int[3];
value.Do(array);
if (array[0] == 1)
This is where my test falls down as array is still the null array declared two lines above and not the array i specified in the mocked method call. Hope this explains what i am trying to achieve and if so is there anyway of doing it. Would also be open to using RhinoMocks as well if it could be done that way.
Thank in advance,
Kev