示例#1
0
 public BindingMatch(IStepDefinitionBinding stepBinding, int scopeMatches, object[] arguments, StepContext stepContext)
 {
     StepBinding = stepBinding;
     ScopeMatches = scopeMatches;
     Arguments = arguments;
     StepContext = stepContext;
 }
示例#2
0
        public bool Match(StepContext stepContext, out int scopeMatches)
        {
            scopeMatches = 0;

            var tags = stepContext.Tags;

            if (Tag != null)
            {
                if (!tags.Contains(Tag))
                    return false;

                scopeMatches++;
            }
            if (FeatureTitle != null)
            {
                if (!string.Equals(FeatureTitle, stepContext.FeatureTitle, StringComparison.CurrentCultureIgnoreCase))
                    return false;

                scopeMatches++;
            }
            if (ScenarioTitle != null)
            {
                if (!string.Equals(ScenarioTitle, stepContext.ScenarioTitle, StringComparison.CurrentCultureIgnoreCase))
                    return false;

                scopeMatches++;
            }

            return true;
        }
示例#3
0
        public StepFailureEventArgs(IStepDefinitionBinding stepDefiniton, StepContext stepContext, Exception exception)
        {
            IsHandled = false;

            StepDefiniton = stepDefiniton;
            StepContext = stepContext;
            Exception = exception;
        }
示例#4
0
 public StepArgs(BindingType type, StepDefinitionKeyword stepDefinitionKeyword, string text, string multilineTextArgument, Table tableArgument, StepContext stepContext)
 {
     Type = type;
     StepDefinitionKeyword = stepDefinitionKeyword;
     Text = text;
     MultilineTextArgument = multilineTextArgument;
     TableArgument = tableArgument;
     StepContext = stepContext;
 }
示例#5
0
 public StepInstance(StepDefinitionType type, StepDefinitionKeyword stepDefinitionKeyword, string keyword, string text, string multilineTextArgument, Table tableArgument, StepContext stepContext)
 {
     StepDefinitionType = type;
     StepDefinitionKeyword = stepDefinitionKeyword;
     Text = text;
     MultilineTextArgument = multilineTextArgument;
     TableArgument = tableArgument;
     StepContext = stepContext;
     Keyword = keyword;
 }
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock))
            {
                var matches = placeholderRe.Matches(text);
                foreach (Match match in matches)
                    ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder);
            }

            var editorLine = stepSpan.StartPosition.Line;
            var tags = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);



            var bindingMatchService = projectScope.BindingMatchService;
         


            if (bindingMatchService.Ready && bindingMatchService != null)
            {
                List<BindingMatch> candidatingMatches;
                candidatingMatches = null;
                StepDefinitionAmbiguityReason ambiguityReason;
                CultureInfo bindingCulture = currentStep.StepContext.Language;
                var match = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches);

                if (candidatingMatches.Count == 0)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);
                }
                else
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.KnownStepText);
                    foreach (String value in candidatingMatches.First().StepBinding.Regex.Split(text))
                        ColorizeLinePart(value, stepSpan, classifications.Variable);
                }
                  

            
            }
            else
                ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

        }
 public GherkinStep(StepDefinitionType stepDefinitionType, StepDefinitionKeyword stepDefinitionKeyword, string stepText, StepContext stepContext, string keyword, int blockRelativeLine)
     : base(stepDefinitionType, stepDefinitionKeyword, keyword, stepText, stepContext)
 {
     BlockRelativeLine = blockRelativeLine;
     BindingStatus = BindingStatus.UnknownBindingStatus;
 }
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

            if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock))
            {
                var matches = placeholderRe.Matches(text);
                foreach (Match match in matches)
                    ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder);
            }

            var editorLine = stepSpan.StartPosition.Line;
            var tags = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);
        }
示例#9
0
 public BindingMatch(IStepDefinitionBinding stepBinding, int scopeMatches, object[] arguments, StepContext stepContext)
 {
     StepBinding  = stepBinding;
     ScopeMatches = scopeMatches;
     Arguments    = arguments;
     StepContext  = stepContext;
 }
        public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan)
        {
            var editorLine = stepSpan.StartPosition.Line;
            var tags = FeatureTags.Concat(CurrentFileBlockBuilder.Tags).Distinct();
            var stepContext = new StepContext(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray(), gherkinFileScope.GherkinDialect.CultureInfo);

            currentStep = new GherkinStep((StepDefinitionType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepContext, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine);
            CurrentFileBlockBuilder.Steps.Add(currentStep);

            var bindingMatchService = projectScope.BindingMatchService;
            if (enableStepMatchColoring && bindingMatchService != null && bindingMatchService.Ready)
            {
                List<BindingMatch> candidatingMatches;
                StepDefinitionAmbiguityReason ambiguityReason;
                CultureInfo bindingCulture = projectScope.SpecFlowProjectConfiguration.RuntimeConfiguration.BindingCulture ?? currentStep.StepContext.Language;
                var match = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches);

                if (match.Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);
                    int linePos = stepSpan.StartPosition.LinePosition;
                    foreach (var stringArg in match.Arguments.OfType<string>())
                    {
                        linePos = ColorizeLinePart(stringArg, stepSpan, classifications.StepArgument, linePos);
                    }
                }
                else if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock) && placeholderRe.Match(text).Success)
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); // we do not show binding errors in placeholdered scenario outline steps
                    //TODO: check match based on the scenario examples - unfortunately the steps are parsed earlier than the examples, so we would need to delay the colorization somehow
                }
                else
                {
                    ColorizeKeywordLine(keyword, stepSpan, classifications.UnboundStepText);
                }
            }
            else
                ColorizeKeywordLine(keyword, stepSpan, classifications.StepText);

            if (CurrentFileBlockBuilder.BlockType == typeof(IScenarioOutlineBlock))
            {
                var matches = placeholderRe.Matches(text);
                foreach (Match match in matches)
                    ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder);
            }
        }
示例#11
0
 public StepInstance(StepDefinitionType stepDefinitionType, StepDefinitionKeyword stepDefinitionKeyword, string keywordWithTrailingSpaces, string text, StepContext stepContext)
         : this(stepDefinitionType, stepDefinitionKeyword, keywordWithTrailingSpaces, text, null, null, stepContext)
 {
 }
示例#12
0
 public StepInstance(StepDefinitionType type, StepDefinitionKeyword stepDefinitionKeyword, string keyword, string text, string multilineTextArgument, Table tableArgument, StepContext stepContext)
 {
     StepDefinitionType    = type;
     StepDefinitionKeyword = stepDefinitionKeyword;
     Text = text;
     MultilineTextArgument = multilineTextArgument;
     TableArgument         = tableArgument;
     StepContext           = stepContext;
     Keyword = keyword;
 }
示例#13
0
 public StepInstance(StepDefinitionType stepDefinitionType, StepDefinitionKeyword stepDefinitionKeyword, string keywordWithTrailingSpaces, string text, StepContext stepContext)
     : this(stepDefinitionType, stepDefinitionKeyword, keywordWithTrailingSpaces, text, null, null, stepContext)
 {
 }