Пример #1
0
 public IGherkinBlockStep this[GherkinStep step]
 {
     get
     {
         return(this.FirstOrDefault(x => x.Step.Syntax == step));
     }
 }
        private static bool IsListed(GherkinStep step, IStepDefinitionMatchService bindingMatchService, CultureInfo bindingCulture)
        {
            List <BindingMatch>           candidatingMatches;
            StepDefinitionAmbiguityReason ambiguityReason;
            var  match    = bindingMatchService.GetBestMatch(step, bindingCulture, out ambiguityReason, out candidatingMatches);
            bool isListed = !match.Success;

            if (isListed && candidatingMatches.Count > 0)
            {
                isListed = ambiguityReason == StepDefinitionAmbiguityReason.AmbiguousScopes; // if it is already ambiguous (except scopes), we rather not list it
            }
            return(isListed);
        }
    public void TestBehindTheMagicOfFluency()
    {
        GherkinStep <int>    givenStep = Gherkin.Given("We have 3", 3);
        GherkinStep <int>    whenStep  = givenStep.When("we multiply it by 3", value => value * 3);
        GherkinStep <double> andStep   = whenStep.And("we multiply the result by 3", value => value * 3.000);

        try {
            andStep.Then("the result is 27", stepResult => stepResult == 27.000); //result is Double
        }
        catch (Exception ex) {
            throw new Exception("Then condition failed:" + ex.Message);
        }
    }
        private GherkinTextCompletionData GETVTDM(GherkinStep GS)
        {
            GherkinTextCompletionData TCD = new GherkinTextCompletionData(GS.Text);

            TCD.Description = "Step: " + GS.Text + " - " + GS.AutomationStatus;

            BitmapImage b = new BitmapImage();

            b.BeginInit();
            b.UriSource = new Uri("pack://*****:*****@AddActivity_16x16.png");
            b.EndInit();
            TCD.Image = b;

            return(TCD);
        }
Пример #5
0
        /// <summary>
        /// Returns the Gherkin Block for the step.
        /// </summary>
        /// <param name="step">The step.</param>
        /// <returns>The corresponding block.</returns>
        public static GherkinScenarioBlock Block(this GherkinStep step)
        {
            switch (step)
            {
            case GherkinStep.Given:
                return(GherkinScenarioBlock.Given);

            case GherkinStep.When:
                return(GherkinScenarioBlock.When);

            case GherkinStep.Then:
                return(GherkinScenarioBlock.Then);

            default:
                return(GherkinScenarioBlock.Then);
            }
        }
Пример #6
0
        public static IFixtureStep Steps(GherkinStep step, IGherkinBlock item)
        {
            var parent = item.Steps[step];

            if (parent == null)
            {
                return(null);
            }

            var result = FixtureStep.Create(parent);

            foreach (var child in item.Steps.Parent(parent.Step.Syntax.Block()))
            {
                result.AddChild(FixtureStep.Create(child));
            }

            return(result);
        }
        private void HighlightStep(GherkinStep step, IHighlightingConsumer consumer)
        {
            var references = step.GetFirstClassReferences();

            if (references.Count != 1 || !(references[0] is SpecflowStepDeclarationReference))
            {
                return;
            }

            SpecflowStepDeclarationReference reference = (SpecflowStepDeclarationReference)references[0];

            var document        = step.GetDocumentRange().Document;
            var parameterRanges = GherkinPsiUtil.BuildParameterRanges(step, reference, reference.GetDocumentRange());

            foreach (var range in parameterRanges)
            {
                var documentRange = new DocumentRange(document, range);
                consumer.AddHighlighting(new ReSharperSyntaxHighlighting(GherkinHighlightingAttributeIds.REGEXP_PARAMETER, null, documentRange));
            }
        }
Пример #8
0
        public ILanguageSyntax <GherkinStep> Get(GherkinStep value)
        {
            switch (value)
            {
            case GherkinStep.Given:
                return(this.step(value, "Given"));

            case GherkinStep.When:
                return(this.step(value, "When"));

            case GherkinStep.Then:
                return(this.step(value, "Then"));

            case GherkinStep.And:
                return(this.step(value, "And"));

            case GherkinStep.But:
                return(this.step(value, "But"));
            }

            return(this.step(value, string.Empty));
        }
Пример #9
0
 public static string Format(this GherkinStep step, string start, string end)
 {
     return(string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", start, step, end));
 }
Пример #10
0
 public static string Format(this GherkinStep step)
 {
     return(step.Format("[", "]"));
 }
Пример #11
0
 public static bool StartsWith(this string line, GherkinStep step)
 {
     return(line.TrimStart().StartsWith(step.ToString(), true, CultureInfo.CurrentCulture));
 }
Пример #12
0
        private static IStepDefinitionBinding GetSingleStepDefinitionBinding(GherkinEditorContext editorContext, GherkinStep step)
        {
            var bindingMatchService = editorContext.LanguageService.ProjectScope.BindingMatchService;

            if (bindingMatchService == null)
            {
                return(null);
            }

            if (!bindingMatchService.Ready)
            {
                MessageBox.Show("Step bindings are still being analyzed. Please wait.", "Go to binding");
                return(null);
            }

            List <BindingMatch>           candidatingMatches;
            StepDefinitionAmbiguityReason ambiguityReason;
            CultureInfo bindingCulture = editorContext.ProjectScope.SpecFlowConfiguration.BindingCulture ?? step.StepContext.Language;
            var         match          = bindingMatchService.GetBestMatch(step, bindingCulture, out ambiguityReason, out candidatingMatches);

            if (candidatingMatches.Count > 1 || !match.Success)
            {
                MessageBox.Show("Cannot rename automatically. You need to have a single and unique binding for this step.");
                return(null);
            }

            return(match.StepBinding);
        }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GherkinSyntaxAttribute"/> class.
 /// </summary>
 /// <param name="step">The step.</param>
 public GherkinSyntaxAttribute(GherkinStep step)
 {
     this.Step = step;
 }
 public NotResolvedError(GherkinStep gherkinStep)
 {
     GherkinStep = gherkinStep;
 }