private void OnWasCalled(LambdaExpression expression) { var rule = new ExpressionCallRule(expression); if (!this.Fake.RecordedCalls.Any(x => rule.IsApplicableTo(x))) { var writer = new StringWriter(CultureInfo.InvariantCulture); this.Fake.RecordedCalls.WriteCalls(writer); var messageTemplate = "Expected to find call {0} but could not find it among the calls: \r\n {1}"; throw new ExpectationException(messageTemplate.FormatInvariant(rule.ToString(), writer.ToString())); } }
private static void ThrowWhenNotCalledWithCorrectRepeat(ExpressionCallRule rule, Expression <Func <int, bool> > repeatValidation, int repeat) { var messageTemplate = ExceptionMessages.WasCalledWrongNumberOfTimes.FormatInvariant(rule.ToString(), repeatValidation.ToString(), repeat); throw new ExpectationException(messageTemplate); }