I’m still learning Rhino mocks and have a question about it. For example – I have a function in mocked interface:
public interface ISomeObject
{
string Name {get; set;}
int Id {get;set;}
}
// This class will be returned as and answer to function call
public class AnswerObject
{
public bool IfError {get;set;}
}
// Main interface
public interface IClass
{
AnswerObject FunctionGetCollection(ref ICollection <ISomeObject> ListOfInternalObjects, ref int Number);
}
As you see the function ‘FunctionGetCollection’ will receive 2 parameters passed as ‘ref’ and return another class as ‘function-answer’. Can you help me to stub this funciton ? I need to be able to use:
- function will return different collection (based in place in code not on parameters)
- function will return different AnswerObject
The syntax is not very nice. It is not used very often and uses the old-style
Rhino.Mocks.Constraints.This piece of code sets up a mock that replaces all the ref-arguments with new values.
If you want to keep the values as they are passed to the mock, you need to implement this in a WhenCalled block: