Hello,
I am wondering if this is possible, tried it with version 3.7 and couldn't succed. I want to return an existing object instance of the return value of a mocked constructor call. To give example, the code to be tested is:
......
Class1 a = new Class1();
a.SomeMethod();
....
this is the tester code:
Class1 ourInstance = new Class1();
....
// initialize properties etc on ourInstance
...
using (RecordExpectation rec = RecorderManager.StartRecording())
{
Class1 c = new Class1();
rec.Return(ourInstance);
}
What we are trying to do, is to have variable "a" in the code being tested to be assigned to the instance ourInstance when the constructor for it being called, which gets mocked. But it appears the rec.Return(ourInstance) statement doesn't have any effect here.
Is it possible to return an instance of our choice as the result of a mocked constructor call?
TIA