Mock a void method which change the input value
- by Kar
Hi,
How could I mock a void method with parameters and change the value parameters?
My void method looks like this:
public interface IFoo
{
void GetValue(int x, object y)
// takes x and do something then access another class to get the value of y
}
I prepared a delegate class:
private delegate void GetValueDelegate(int x, object y);
private void GetValue(int x, object y)
{ // process x
// prepare a new object obj
if (y == null) y = new Object();
if (//some checks)
y = obj;
}
I wrote something like this:
Expect.Call(delegate {x.GetValue(5, null);}).Do (new GetValueDelegate(GetValue)).IgnoreArguments().Repeat.Any();
But seems like it's not working. Any clue on what could be wrong?