Exemplo n.º 1
0
        private Feature CreateFeature(string[] tags = null)
        {
            tags = tags ?? new string[0];

            Scenario scenario1 = new Scenario("Scenario", "scenario1 title", "", new Tags(), new ScenarioSteps());

            return new Feature("feature", "title", new Tags(tags.Select(t => new Tag(t)).ToArray()), "desc", null, new Scenario[] {scenario1}, new Comment[0]);
        }
        private static Feature CreateFeature(bool featureIgnore = false, bool scenarioIgnore = false, bool scenarioOutlineIgnore = false)
        {
            var scenario1 = new Scenario("Scenario", "scenario title", "", CreateTags(scenarioIgnore), new ScenarioSteps());
            var scenario2 = new ScenarioOutline("Scenarios", "scenarios title", "", CreateTags(scenarioOutlineIgnore), new ScenarioSteps(),
                new Examples(new ExampleSet("","","",new Tags(),new GherkinTable(new GherkinTableRow(new GherkinTableCell[]{})) )));

            return new Feature("feature", "title", CreateTags(featureIgnore), "desc", null, new[] { scenario1, scenario2 }, new Comment[0]);
        }
Exemplo n.º 3
0
 public Feature(string keyword, string title, Tags tags, string description, Background background, Scenario[] scenarios, Comment[] comments)
 {
     Keyword = keyword;
     Title = title;
     Tags = tags;
     Description = description ?? string.Empty;
     Background = background;
     Scenarios = scenarios;
     Comments = comments;
 }
        private static string GetPlainText(string fileName, Scenario scenario, Feature feature)
        {
            var lines = File.ReadAllLines(fileName);

            var nextScenario = feature.Scenarios.SkipWhile(s => s != scenario).Skip(1).FirstOrDefault();

            int startLine = scenario.FilePosition.Line;
            int endLine = nextScenario == null ? lines.Count() : nextScenario.FilePosition.Line - 1;

            return string.Join(Environment.NewLine, lines.Skip(startLine - 1).Take(endLine - startLine + 1)).Replace("\t", "  ");
        }
 public static ScenarioVm CreateFromSpecFlowScenario(Scenario specFlowScenario)
 {
     return new ScenarioVm
                {
                    Description = specFlowScenario.Description,
                    Keyword = specFlowScenario.Keyword,
                    Steps = StepListVm.CreateFromSpecFlowScenarioSteps(specFlowScenario.Steps),
                    Tags = specFlowScenario.Tags,
                    Title = specFlowScenario.Title
                };
 }
        public static string FormatHtml(Scenario scenario)
        {
            StringBuilder formettedScenario = new StringBuilder();

            formettedScenario.AppendLine("<div class='gherkin-scenario'>");

            ScenarioOutline scenarioOutline = scenario as ScenarioOutline;

            foreach (var scenarioStep in scenario.Steps)
                AddStep(scenarioStep, scenarioOutline != null, formettedScenario);

            if (scenarioOutline != null)
            {
                //TODO
            }

            formettedScenario.AppendLine("</div>");

            return formettedScenario.ToString();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Converts the provided <see cref="SpecFlow.Scenario"/> instance into a <see cref="Augurk.Entities.Scenario"/> instance.
        /// </summary>
        /// <param name="scenario">The <see cref="SpecFlow.Scenario"/> instance that should be converted.</param>
        /// <returns>The converted <see cref="Augurk.Entities.Scenario"/> instance.</returns>
        public static Scenario ConvertToScenario(this SpecFlow.Scenario scenario)
        {
            if (scenario == null)
            {
                throw new ArgumentNullException("scenario");
            }

            SpecFlow.ScenarioOutline outline = scenario as SpecFlow.ScenarioOutline;
            if (outline != null)
            {
                return(outline.ConvertToScenario());
            }

            return(new Scenario()
            {
                Title = scenario.Title,
                Description = scenario.Description,
                Tags = scenario.Tags.ConvertToStrings(),
                Steps = scenario.Steps.ConvertToSteps()
            });
        }
Exemplo n.º 8
0
 protected virtual void AppendScenarioLine(StringBuilder result, Scenario scenario, GherkinDialect dialect, bool isOutline)
 {
     AppendNodeLine(result, scenario.FilePosition, "{0}: {1}",
         dialect.GetBlockKeywords(isOutline ? GherkinBlockKeyword.ScenarioOutline : GherkinBlockKeyword.Scenario).First(),
         scenario.Title);
     if (!string.IsNullOrEmpty(scenario.Description))
         AppendMulitLine(result, scenario.Description);
 }
Exemplo n.º 9
0
 protected ScenarioViewModelBase(Scenario scenario, Feature parentFeature)
 {
     _parentFeature = parentFeature;
     ScenarioNode = scenario;
 }
 string AnchorName(Feature feature, Scenario scenario)
 {
     return "Scenario" + feature.Title.Replace(" ", "_") + scenario.Title.Replace(" ", "_");
 }
    // $ANTLR end "scenarioOutline"


    // $ANTLR start "scenario"
    // SpecFlowLangWalker.g:108:1: scenario returns [Scenario scenario] : ^( SCENARIO (tags_= tags )? title_= text steps_= steps fp_= fileposition ) ;
    public Scenario scenario() // throws RecognitionException [1]
    {   
        Scenario scenario = default(Scenario);

        Tags tags_ = default(Tags);

        Text title_ = default(Text);

        ScenarioSteps steps_ = default(ScenarioSteps);

        FilePosition fp_ = default(FilePosition);


        try 
    	{
            // SpecFlowLangWalker.g:113:5: ( ^( SCENARIO (tags_= tags )? title_= text steps_= steps fp_= fileposition ) )
            // SpecFlowLangWalker.g:113:9: ^( SCENARIO (tags_= tags )? title_= text steps_= steps fp_= fileposition )
            {
            	Match(input,SCENARIO,FOLLOW_SCENARIO_in_scenario733); 

            	Match(input, Token.DOWN, null); 
            	// SpecFlowLangWalker.g:114:18: (tags_= tags )?
            	int alt10 = 2;
            	int LA10_0 = input.LA(1);

            	if ( (LA10_0 == TAGS) )
            	{
            	    alt10 = 1;
            	}
            	switch (alt10) 
            	{
            	    case 1 :
            	        // SpecFlowLangWalker.g:114:18: tags_= tags
            	        {
            	        	PushFollow(FOLLOW_tags_in_scenario750);
            	        	tags_ = tags();
            	        	state.followingStackPointer--;


            	        }
            	        break;

            	}

            	PushFollow(FOLLOW_text_in_scenario767);
            	title_ = text();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_steps_in_scenario783);
            	steps_ = steps();
            	state.followingStackPointer--;

            	PushFollow(FOLLOW_fileposition_in_scenario799);
            	fp_ = fileposition();
            	state.followingStackPointer--;


            	Match(input, Token.UP, null); 

            }


                scenario =  new Scenario(title_, tags_, steps_);
                scenario.FilePosition = fp_;

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return scenario;
    }
Exemplo n.º 12
0
 public ScenarioViewModel(Feature feature, Scenario scenario)
     : base(scenario, feature)
 {
     var bgSteps = feature.Background != null ? feature.Background.Steps.AsEnumerable() : Enumerable.Empty<ScenarioStep>();
     Steps = bgSteps.Concat(scenario.Steps).Select(x => new StepViewModel(x)).ToList();
 }