Exemplo n.º 1
0
 public BindingMatch(IStepDefinitionBinding stepBinding, int scopeMatches, object[] arguments, StepContext stepContext)
 {
     StepBinding = stepBinding;
     ScopeMatches = scopeMatches;
     Arguments = arguments;
     StepContext = stepContext;
 }
Exemplo n.º 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;
        }
Exemplo n.º 3
0
        public StepFailureEventArgs(IStepDefinitionBinding stepDefiniton, StepContext stepContext, Exception exception)
        {
            IsHandled = false;

            StepDefiniton = stepDefiniton;
            StepContext = stepContext;
            Exception = exception;
        }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 11
0
 public StepInstance(StepDefinitionType stepDefinitionType, StepDefinitionKeyword stepDefinitionKeyword, string keywordWithTrailingSpaces, string text, StepContext stepContext)
         : this(stepDefinitionType, stepDefinitionKeyword, keywordWithTrailingSpaces, text, null, null, stepContext)
 {
 }
Exemplo n.º 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;
 }
Exemplo n.º 13
0
 public StepInstance(StepDefinitionType stepDefinitionType, StepDefinitionKeyword stepDefinitionKeyword, string keywordWithTrailingSpaces, string text, StepContext stepContext)
     : this(stepDefinitionType, stepDefinitionKeyword, keywordWithTrailingSpaces, text, null, null, stepContext)
 {
 }