public void Setup()
        {
            this.trapper = A.Fake<IArgumentConstraintTrapper>();

            Fake.GetFakeManager(this.trapper).AddInterceptionListener(new InvokeTrapConstraintsAction());

            this.factory = new ExpressionArgumentConstraintFactory(this.trapper);
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
        /// <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;
        }
コード例 #4
0
        /// <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;
        }
コード例 #5
0
        /// <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;
        }
コード例 #6
0
        /// <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;
        }
コード例 #7
0
        /// <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;
        }
コード例 #8
0
        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));
        }
コード例 #9
0
 private static IEnumerable <IArgumentConstraint> GetArgumentConstraints(IEnumerable <ParsedArgumentExpression> argumentExpressions, ExpressionArgumentConstraintFactory constraintFactory) =>
 from argument in argumentExpressions
 select constraintFactory.GetArgumentConstraint(argument);
コード例 #10
0
        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);
        }