When I record chained expectations like this:
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.ExpectAndReturn(httpContext.Request.AppRelativeCurrentExecutionFilePath, requestedPath).RepeatAlways();
recorder.ExpectAndReturn(httpContext.Request.[token1], token1Value);
recorder.FailWhenCalled(httpContext.Request.[token1]);
}
I'm getting an expectation error:
Method System.Web.HttpContext.get_Request() has 1 more expected calls
And the tracer shows 3 instances of System.Web.HttpRequest being mocked.
This all looks like right (except the failed statement).
What I should be doing is:
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.ExpectAndReturn(httpContext.Request, httpRequest).RepeatAlways();
recorder.ExpectAndReturn(httpRequest.AppRelativeCurrentExecutionFilePath, requestedPath).RepeatAlways();
recorder.ExpectAndReturn(httpRequest.[token1], token1Value);
recorder.FailWhenCalled(httpRequest.[token1]);
}
But I'm too lazy.
Is there a:
recorder.AlwaysMockTheSameIfCalled(httpContext.Request);
for the lazy guy like me?