private void ReplaceExpectation(IExpectation anyArgsExpectation)
 {
     //All other expectations ignore arguments, so it's safe to replace
     //arguments when the previous expectation is any args.
     if (expectationReplaced && !(expectation is AnyArgsExpectation))
     {
         string message = "This method has already been set to " + expectation.GetType().Name + ".";
         throw new InvalidOperationException(message);
     }
     repository.Recorder.ReplaceExpectation(proxy, expectation.Method, expectation, anyArgsExpectation);
     expectation            = anyArgsExpectation;
     record.LastExpectation = expectation;
     expectationReplaced    = true;
 }