I have a piece of logic that I want to test, and it uses an injection interface depending on one (or more) void methods, for example:
interface IMyService
{
void MethodA (MyComplexObject arg1, int arg2);
}
I would like to create a stub for this IMyServicethat simply recorded the method calls MethodA, and later I could access it as a list, something like
MyComplexObject actualParameter = serviceRecorder
.GetMethodRecordings("MethodA").GetRecord(10).GetInputParameter(0);
I need this to examine the contents of such a parameter for a specific call and make statements on it. I know that others have done this (for example, setting expectations of expectations with restrictions), but it is much easier to write for cases where you have many calls and you want, for example, to make statements only on the 51st.
So, is there any mechanism in Rhino.Mocks for this, or have I gone to my own devices (recording a dummy implementation IMyServicewith write capability)?
NOTE: (I know that this can lead to fragility of the tests, and I know the consequences).
UPDATE: this is what I have found so far (partly thanks to Mark's help in naming this template as Test Spy):
source
share