示例#1
0
        /// <summary>
        /// Provides <see cref="IStepNameInfo"/> object containing information about step name represented by <paramref name="stepDescriptor"/>.
        /// The <paramref name="previousStepTypeName"/> represents the step type name of previous step.
        /// <para>
        /// The <see cref="IStepNameInfo.StepTypeName"/> is determined from value <see cref="StepDescriptor.PredefinedStepType"/> or parsed from <see cref="StepDescriptor.RawName"/> if former is <c>null</c>.
        /// When determined step type is the same as <paramref name="previousStepTypeName"/>, it is being replaced with <see cref="StepTypeConfiguration.RepeatedStepReplacement"/>.
        /// </para>
        /// See also: <seealso cref="StepTypeConfiguration"/>, <seealso cref="LightBddConfiguration"/>.
        /// </summary>
        /// <param name="stepDescriptor">Step descriptor.</param>
        /// <param name="previousStepTypeName">Step type name of previous step, or <c>null</c> if current step is first one.</param>
        /// <returns><see cref="IStepNameInfo"/> object.</returns>
        public IStepNameInfo GetStepName(StepDescriptor stepDescriptor, string previousStepTypeName)
        {
            var formattedStepName = _nameParser.GetNameFormat(stepDescriptor.MethodInfo, stepDescriptor.RawName, stepDescriptor.Parameters);

            return(new StepNameInfo(
                       _stepTypeProcessor.GetStepTypeName(stepDescriptor.PredefinedStepType, ref formattedStepName, previousStepTypeName),
                       formattedStepName,
                       stepDescriptor.Parameters.Select(p => NameParameterInfo.Unknown).ToArray()));
        }
示例#2
0
        /// <summary>
        /// Returns a collection of <see cref="IStepDecorator"/> decorators that are applied on step described by <paramref name="stepDescriptor"/> parameter.
        /// The <see cref="IStepDecorator"/> are inferred from method attributes that implements <see cref="IStepDecoratorAttribute"/> type.
        /// The returned collection would be sorted ascending based on <see cref="IOrderedAttribute.Order"/> property.
        /// </summary>
        /// <param name="stepDescriptor">Step descriptor.</param>
        /// <returns>Collection of decorators or empty collection if none are present.</returns>
        public IEnumerable <IStepDecorator> GetStepDecorators(StepDescriptor stepDescriptor)
        {
            if (stepDescriptor.MethodInfo == null)
            {
                return(Enumerable.Empty <IStepDecorator>());
            }

            return(ExtractAttributes <IStepDecoratorAttribute>(stepDescriptor.MethodInfo)
                   .OrderBy(x => x.Order));
        }
示例#3
0
        /// <summary>
        /// Returns a collection of <see cref="IStepDecorator"/> decorators that are applied on step described by <paramref name="stepDescriptor"/> parameter.
        /// The <see cref="IStepDecorator"/> are inferred from declaring type and method attributes that implements <see cref="IStepDecoratorAttribute"/> type.
        /// The returned collection would be sorted ascending based on <see cref="IOrderedAttribute.Order"/> from declaring type and then based on <see cref="IOrderedAttribute.Order"/> from method.
        /// </summary>
        /// <param name="stepDescriptor">Step descriptor.</param>
        /// <returns>Collection of decorators or empty collection if none are present.</returns>
        public IEnumerable <IStepDecorator> GetStepDecorators(StepDescriptor stepDescriptor)
        {
            if (stepDescriptor.MethodInfo == null)
            {
                return(Enumerable.Empty <IStepDecorator>());
            }

            return(ConcatAndOrderAttributes(
                       ExtractAttributes <IStepDecoratorAttribute>(stepDescriptor.MethodInfo.DeclaringType),
                       ExtractAttributes <IStepDecoratorAttribute>(stepDescriptor.MethodInfo)));
        }