public void Setup() { this.trapper = A.Fake<IArgumentConstraintTrapper>(); Fake.GetFakeManager(this.trapper).AddInterceptionListener(new InvokeTrapConstraintsAction()); this.factory = new ExpressionArgumentConstraintFactory(this.trapper); }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionCallMatcher" /> class. /// </summary> /// <param name="parsedExpression">The parsed call specification.</param> /// <param name="constraintFactory">The constraint factory.</param> /// <param name="methodInfoManager">The method info manager to use.</param> public ExpressionCallMatcher(ParsedCallExpression parsedExpression, ExpressionArgumentConstraintFactory constraintFactory, MethodInfoManager methodInfoManager) { this.methodInfoManager = methodInfoManager; this.Method = parsedExpression.CalledMethod; this.argumentConstraints = GetArgumentConstraints(parsedExpression.ArgumentsExpressions, constraintFactory).ToArray(); this.argumentsPredicate = this.ArgumentsMatchesArgumentConstraints; }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionCallMatcher" /> class. /// </summary> /// <param name="parsedExpression">The parsed call specification.</param> /// <param name="constraintFactory">The constraint factory.</param> /// <param name="methodInfoManager">The method info manager to use.</param> /// <param name="outputWriterFactory">The output writer factory to use.</param> public ExpressionCallMatcher(ParsedCallExpression parsedExpression, ExpressionArgumentConstraintFactory constraintFactory, MethodInfoManager methodInfoManager, StringBuilderOutputWriter.Factory outputWriterFactory) { this.methodInfoManager = methodInfoManager; this.outputWriterFactory = outputWriterFactory; this.Method = parsedExpression.CalledMethod; this.argumentConstraints = GetArgumentConstraints(parsedExpression.ArgumentsExpressions, constraintFactory).ToArray(); this.argumentsPredicate = this.ArgumentsMatchesArgumentConstraints; }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionCallMatcher" /> class. /// </summary> /// <param name="callSpecification">The call specification.</param> /// <param name="constraintFactory">The constraint factory.</param> /// <param name="methodInfoManager">The method info manager to use.</param> /// <param name="callExpressionParser">A parser to use to parse call expressions.</param> public ExpressionCallMatcher(LambdaExpression callSpecification, ExpressionArgumentConstraintFactory constraintFactory, MethodInfoManager methodInfoManager, ICallExpressionParser callExpressionParser) { this.methodInfoManager = methodInfoManager; var parsedExpression = callExpressionParser.Parse(callSpecification); this.Method = parsedExpression.CalledMethod; this.argumentConstraints = GetArgumentConstraints(parsedExpression.ArgumentsExpressions, constraintFactory).ToArray(); this.argumentsPredicate = this.ArgumentsMatchesArgumentConstraints; }
/// <summary> /// Initializes a new instance of the <see cref="ExpressionCallMatcher" /> class. /// </summary> /// <param name="parsedExpression">The parsed call specification.</param> /// <param name="constraintFactory">The constraint factory.</param> /// <param name="methodInfoManager">The method info manager to use.</param> public ExpressionCallMatcher(ParsedCallExpression parsedExpression, ExpressionArgumentConstraintFactory constraintFactory, MethodInfoManager methodInfoManager) { this.methodInfoManager = methodInfoManager; this.Method = parsedExpression.CalledMethod; var constraints = new IArgumentConstraint[parsedExpression.ArgumentsExpressions.Length]; for (var i = 0; i < constraints.Length; i++) { constraints[i] = constraintFactory.GetArgumentConstraint(parsedExpression.ArgumentsExpressions[i]); } this.argumentConstraints = constraints; this.argumentsPredicate = this.ArgumentsMatchesArgumentConstraints; }
private static IEnumerable <IArgumentConstraint> GetArgumentConstraints(IEnumerable <ParsedArgumentExpression> argumentExpressions, ExpressionArgumentConstraintFactory constraintFactory) { if (argumentExpressions == null) { return(Enumerable.Empty <IArgumentConstraint>()); } return (from argument in argumentExpressions select constraintFactory.GetArgumentConstraint(argument)); }
private static IEnumerable <IArgumentConstraint> GetArgumentConstraints(IEnumerable <ParsedArgumentExpression> argumentExpressions, ExpressionArgumentConstraintFactory constraintFactory) => from argument in argumentExpressions select constraintFactory.GetArgumentConstraint(argument);
private static IEnumerable<IArgumentConstraint> GetArgumentConstraints(IEnumerable<ParsedArgumentExpression> argumentExpressions, ExpressionArgumentConstraintFactory constraintFactory) { if (argumentExpressions == null) { return Enumerable.Empty<IArgumentConstraint>(); } return from argument in argumentExpressions select constraintFactory.GetArgumentConstraint(argument); }