예제 #1
0
        public MatchResultItem Match(Step step, IGherkinDocumentContext context, string stepText = null)
        {
            if (!IsValid || !(step is DeveroomGherkinStep deveroomGherkinStep))
            {
                return(null);
            }
            if (deveroomGherkinStep.ScenarioBlock != StepDefinitionType)
            {
                return(null);
            }
            stepText = stepText ?? step.Text;
            var match = Regex.Match(stepText);

            if (!match.Success)
            {
                return(null);
            }

            //check scope
            if (Scope != null && !Scope.Evaluate(context.GetTagNames()))
            {
                return(null);
            }

            var parameterMatch = MatchParameter(step, match);

            return(MatchResultItem.CreateMatch(this, parameterMatch));
        }
예제 #2
0
        private MatchResultItem[] MatchSingleContextResult(Step step, IGherkinDocumentContext context, string stepText = null)
        {
            stepText = stepText ?? step.Text;
            var sdMatches = StepDefinitions.Select(sd => sd.Match(step, context, stepText)).Where(m => m != null).ToArray();

            if (!sdMatches.Any())
            {
                return new[] { MatchResultItem.CreateUndefined(step, stepText) }
            }
            ;

            sdMatches = HandleDataTableOverloads(step, sdMatches);
            sdMatches = HandleDocStringOverloads(step, sdMatches);
            sdMatches = HandleArgumentlessOverloads(step, sdMatches);
            sdMatches = HandleScopeOverloads(sdMatches);

            if (sdMatches.Length == 1)
            {
                return new[] { sdMatches[0] }
            }
            ;

            return(sdMatches.Select(mi => mi.CloneToAmbiguousItem()).ToArray());
        }