Exemple #1
0
        private object[] GetExecuteArguments(BindingMatch match)
        {
            List<object> arguments = new List<object>();

            var regexArgs = match.Match.Groups.Cast<Group>().Skip(1).Select(g => g.Value).ToArray();

            if (regexArgs.Length > match.StepBinding.ParameterTypes.Length)
                throw errorProvider.GetParameterCountError(match, regexArgs.Length + (match.ExtraArguments == null ? 0 : match.ExtraArguments.Length));

            for (int argIndex = 0; argIndex < regexArgs.Length; argIndex++)
            {
                var convertedArg = stepArgumentTypeConverter.Convert(regexArgs[argIndex], match.StepBinding.ParameterTypes[argIndex],
                    FeatureContext.Current.FeatureInfo.CultureInfo);
                arguments.Add(convertedArg);
            }

            if (match.ExtraArguments != null)
                arguments.AddRange(match.ExtraArguments);

            if (arguments.Count != match.StepBinding.ParameterTypes.Length)
                throw errorProvider.GetParameterCountError(match, arguments.Count);

            return arguments.ToArray();
        }
Exemple #2
0
        private TimeSpan ExecuteStepMatch(BindingMatch match, object[] arguments)
        {
            OnStepStart();
            TimeSpan duration = InvokeAction(match.StepBinding.BindingAction, arguments, match.StepBinding.MethodInfo);
            OnStepEnd();

            return duration;
        }