private IEnumerable <ICompletedFakeObjectCall> OnMatching(LambdaExpression callSpecification) { var rule = new ExpressionCallRule(callSpecification); return (from call in this.Fake.RecordedCallsInScope where rule.IsApplicableTo(call) select call); }
private void OnWasNotCalled(LambdaExpression expression) { var rule = new ExpressionCallRule(expression); if (this.Fake.RecordedCalls.Any(x => rule.IsApplicableTo(x))) { throw new ExpectationException("Expected call not to be found but found it."); } }
private void OnWasCalled(LambdaExpression expression, Expression <Func <int, bool> > repeatValidation) { var rule = new ExpressionCallRule(expression); var repeat = this.Fake.RecordedCallsInScope.Where(x => rule.IsApplicableTo(x)).Count(); if (!repeatValidation.Compile().Invoke(repeat)) { ThrowWhenNotCalledWithCorrectRepeat(rule, repeatValidation, repeat); } }
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())); } }