Hi all,
What do you think of this way:
public object ReturnRefValues(object[] parameters, object context)
{
Dictionary<string, string> dummy = parameters[0] as Dictionary<string, string>;
dummy.Add("", "");
return null;
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void stam()
{
Mock mock = MockManager.Mock<MethodContainer>();
mock.ExpectAndReturn("Method",new DynamicReturnValue(ReturnRefValues));
MethodContainer target = new MethodContainer();
target.CallingMethod();
}
and in Natural:
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void stam_natural()
{
using (RecordExpectations rec = new RecordExpectations())
{
MethodContainer mock = new MethodContainer();
mock.Method(null);
rec.Return(new DynamicReturnValue(ReturnRefValues));
}
MethodContainer target = new MethodContainer();
target.CallingMethod();
}
In any case I really liked Paulo idea for the ExpectAndCall API.
:!: Its worth mentioning that for cases where the sent argument is a ref/out the
Assign API can be used to change the value of argument:
mock.ExpectCall("Method").Args(new Assign(fakeValue));