public StepBuilder(string keyword, StepKeyword stepKeyword, string text, FilePosition position, ScenarioBlock scenarioBlock) { switch (stepKeyword) { case StepKeyword.Given: step = new Given(); break; case StepKeyword.When: step = new When(); break; case StepKeyword.Then: step = new Then(); break; case StepKeyword.And: step = new And(); break; case StepKeyword.But: step = new But(); break; default: throw new NotSupportedException(); } step.Keyword = keyword; step.Text = text; step.FilePosition = position; step.ScenarioBlock = scenarioBlock; step.StepKeyword = stepKeyword; }
private void GenerateStep(CodeStatementCollection statements, Step scenarioStep, ParameterSubstitution paramToIdentifier, TableRow row, StepKeyword stepKeyWord, string keyWord) { var specFlowStep = AsSpecFlowStep(scenarioStep); //testRunner.Given("something"); var arguments = new List <CodeExpression> { GetSubstitutedString(scenarioStep.Text, paramToIdentifier, row), GetDocStringArgExpression(scenarioStep.Argument as DocString, paramToIdentifier, row), GetTableArgExpression(scenarioStep.Argument as DataTable, statements, paramToIdentifier, row), new CodePrimitiveExpression(keyWord) }; AddLineDirective(statements, scenarioStep); statements.Add(new CodeExpressionStatement( new CodeMethodInvokeExpression( new CodeMethodReferenceExpression( new CodeVariableReferenceExpression(NamingHelper.TestRunnerVariableName), stepKeyWord.ToString()), arguments.ToArray()))); }
public StepBuilder(string keyword, StepKeyword stepKeyword, string text, FilePosition position) { switch (stepKeyword) { case StepKeyword.Given: step = new Given(); break; case StepKeyword.When: step = new When(); break; case StepKeyword.Then: step = new Then(); break; case StepKeyword.And: step = new And(); break; case StepKeyword.But: step = new But(); break; default: throw new NotSupportedException(); } step.Keyword = keyword; step.Text = text; step.FilePosition = position; }
public ReportStep(Location location, string keyword, string text, ReportStepArgument argument, StepKeyword stepKeyword, Parser.ScenarioBlock scenarioBlock) { //Location = location; Keyword = keyword; Text = text; Argument = argument; ScenarioBlock = scenarioBlock; StepKeyword = stepKeyword; }
public void Step(string keyword, StepKeyword stepKeyword, Parser.Gherkin.ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan) { // RaringCoder: When a new step is created, we check to see if the previous step had a table, if so we outline it. CheckTableOutline(); 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 + keyword.Length; 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); } } }
public void step(string keyword, string text, int line) { FlushDelayedCalls(); ResetStepArguments(); var stepSpan = ProcessSimpleLanguageElement(line); StepKeyword stepKeyword = gherkinDialect.TryParseStepKeyword(keyword) ?? StepKeyword.And; // if we dont find it, we suppose an "and" ScenarioBlock scenarioBlock = CalculateScenarioBlock(stepKeyword); gherkinListener.Step(keyword, stepKeyword, scenarioBlock, text, stepSpan); }
public void Step(string keyword, StepKeyword stepKeyword, ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan) { var position = GetFilePosition(stepSpan.StartPosition); stepBuilder = new StepBuilder(keyword, stepKeyword, text, position, scenarioBlock); tableProcessor = stepBuilder; if (stepProcessor == null) { throw new GherkinSemanticErrorException( "Steps can only be specified for scenarios or scenario outlines.", position); } stepProcessor.ProcessStep(stepBuilder); }
public static ScenarioBlock?ToScenarioBlock(this StepKeyword stepKeyword) { switch (stepKeyword) { case StepKeyword.Given: return(ScenarioBlock.Given); case StepKeyword.When: return(ScenarioBlock.When); case StepKeyword.Then: return(ScenarioBlock.Then); } return(null); }
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); } } //TODO: register step }
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 stepScope = new StepScopeNew(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray()); currentStep = new GherkinStep((BindingType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepScope, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine); CurrentFileBlockBuilder.Steps.Add(currentStep); }
private ScenarioBlock CalculateScenarioBlock(StepKeyword stepKeyword) { switch (stepKeyword) { case StepKeyword.Given: lastScenarioBlock = ScenarioBlock.Given; break; case StepKeyword.When: lastScenarioBlock = ScenarioBlock.When; break; case StepKeyword.Then: lastScenarioBlock = ScenarioBlock.Then; break; default: // keep the existing one break; } return(lastScenarioBlock); }
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 stepScope = new StepScope(FeatureTitle, CurrentFileBlockBuilder.BlockType == typeof(IBackgroundBlock) ? null : CurrentFileBlockBuilder.Title, tags.ToArray()); currentStep = new GherkinStep((BindingType)scenarioBlock, (StepDefinitionKeyword)stepKeyword, text, stepScope, keyword, editorLine - CurrentFileBlockBuilder.KeywordLine); CurrentFileBlockBuilder.Steps.Add(currentStep); }
public DeveroomGherkinStep(Location location, string keyword, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument) { StepKeyword = stepKeyword; ScenarioBlock = scenarioBlock; }
private void FixStepKeyWordForScenarioStep(SpecFlowFeature feature, SpecFlowStep executionStep, SpecFlowStep testingStep, out StepKeyword stepKeyWord, out string keyWord) { stepKeyWord = executionStep.StepKeyword; keyWord = executionStep.Keyword; if (executionStep.StepKeyword == StepKeyword.And) { int scenarioStepIndex = feature.Background.Steps.ToList().IndexOf(executionStep); int stepIndex = feature.Background.Steps.ToList().IndexOf(testingStep); if (scenarioStepIndex == stepIndex + 1) { stepKeyWord = testingStep.StepKeyword; keyWord = testingStep.Keyword; } } }
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); } //TODO: register step }
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.SpecFlowConfiguration.BindingCulture ?? currentStep.StepContext.Language; var match = bindingMatchService.GetBestMatch(currentStep, bindingCulture, out ambiguityReason, out candidatingMatches); if (match.Success) { ColorizeKeywordLine(keyword, stepSpan, classifications.StepText); var regexMatch = match.StepBinding.Regex.Match(text); if (regexMatch.Success) { var textStart = KeywordAndWhitespaceLength(keyword, stepSpan, editorLine); foreach (Group matchGroup in regexMatch.Groups.Cast <Group>().Skip(1)) { var captures = matchGroup.Captures; var lastCapture = captures[captures.Count - 1]; var partStart = textStart + captures[0].Index; var partEnd = textStart + lastCapture.Index + lastCapture.Length; ColorizeLinePart(partStart, partEnd, stepSpan, classifications.StepArgument); } } else { // this should never happen } } 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); var textStart = KeywordAndWhitespaceLength(keyword, stepSpan, editorLine); foreach (Match match in matches) { var capture = match.Groups[0].Captures[0]; var start = textStart + capture.Index; ColorizeLinePart(start, start + capture.Length, stepSpan, classifications.Placeholder); } } }
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); } }
protected Step CreateStep(StepKeyword stepKeyword = StepKeyword.Given, string text = "my step", StepArgument stepArgument = null) { return(new DeveroomGherkinStep(null, stepKeyword + " ", text, stepArgument, stepKeyword, (ScenarioBlock)stepKeyword)); }
private static ScenarioStep CreateTestStep(string text, StepKeyword stepKeyword) { return new ScenarioStep {Text = text, StepKeyword = stepKeyword}; }
public IEnumerable<string> GetStepKeywords(StepKeyword stepKeyword) { return NativeLanguageService.keywords(stepKeyword.ToString().ToLowerInvariant()).toArray().Cast<string>(); }
public void Step(string keyword, StepKeyword stepKeyword, ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan) { var position = GetFilePosition(stepSpan.StartPosition); stepBuilder = new StepBuilder(keyword, stepKeyword, text, position, scenarioBlock); tableProcessor = stepBuilder; if (stepProcessor == null) throw new GherkinSemanticErrorException( "Steps can only be specified for scenarios or scenario outlines.", position); stepProcessor.ProcessStep(stepBuilder); }
public SpecFlowStep(Location location, string keyword, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument) { StepKeyword = stepKeyword; ScenarioBlock = scenarioBlock; }
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 ScenarioStep CreateStep(string keyword, StepKeyword stepKeyword, string text, FilePosition position, ScenarioBlock scenarioBlock) { ScenarioStep step; switch (stepKeyword) { case StepKeyword.Given: step = new Given(); break; case StepKeyword.When: step = new When(); break; case StepKeyword.Then: step = new Then(); break; case StepKeyword.And: step = new And(); break; case StepKeyword.But: step = new But(); break; default: throw new NotSupportedException(); } step.Keyword = keyword; step.Text = text; step.FilePosition = position; step.ScenarioBlock = scenarioBlock; step.StepKeyword = stepKeyword; return step; }
private ScenarioBlock CalculateScenarioBlock(StepKeyword stepKeyword) { switch (stepKeyword) { case StepKeyword.Given: lastScenarioBlock = ScenarioBlock.Given; break; case StepKeyword.When: lastScenarioBlock = ScenarioBlock.When; break; case StepKeyword.Then: lastScenarioBlock = ScenarioBlock.Then; break; default: // keep the existing one break; } return lastScenarioBlock; }
public IEnumerable <string> GetStepKeywords(StepKeyword stepKeyword) { return(NativeLanguageService.keywords(stepKeyword.ToString().ToLowerInvariant()).toArray().Cast <string>()); }
public void Step(string keyword, StepKeyword stepKeyword, ScenarioBlock scenarioBlock, string text, GherkinBufferSpan stepSpan) { RegisterKeyword(keyword, stepSpan); var scenario = gherkinFileEditorInfo.ScenarioEditorInfos.LastOrDefault(); if (scenario == null) return; if (scenario.IsScenarioOutline) { var matches = placeholderRe.Matches(text); foreach (Match match in matches) ColorizeLinePart(match.Value, stepSpan, classifications.Placeholder); } }