Right - here's the scenario:
I want to stub an asynch service call. On the service call, I want to
inspect the service call parameters, and implement return logic based
on the parameters passed.
Problem: It seems stubbed "WhenCalled" is fired before the method is
actually fired.
Code:
stub the service method call in TestSetup:
ServiceMock.Stub(x => x.SaveRecordAsync(0, null)).Constraints
(Is.Anything()).WhenCalled(OnSaveRecordCompleted(ServiceMock));
//Problem: Called immidiately on stub - args is null??
private static Action<MethodInvocation> OnSaveRecordCompleted
(IServiceClient service)
{
IList<object[]> args = service.GetArgumentsForCallsMadeOn
(x => x.SaveReecordAsync(0, null));
if (args.Count > 0)
{
MyRecord saveParam = args.First()[1] as MyRecord;
return y => service.Raise(x => x.SaveRecordCompleted
+= null, null, new SaveRecordCompletedEventArgs(new[]
{saveParam.MimicServerSave()}, null, false, null));
}
return null;
}
How do I get OnSaveRecordCompleted to be called only when the
SaveRecordAsycn() method is actually called, so that I can access the
SaveRecordAsynch parameters?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---