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]);
        }
        public ScenarioOutlineViewModel(Feature feature, ScenarioOutline scenarioOutline)
            : base(scenarioOutline, feature)
        {
            var bgSteps = feature.Background != null ? feature.Background.Steps.AsEnumerable() : Enumerable.Empty<ScenarioStep>();

            StepTemplates = bgSteps.Concat(scenarioOutline.Steps).Select(x => new StepTemplateViewModel(x)).ToList();

            Examples = scenarioOutline.Examples.ExampleSets.Select(x => new ScenarioOutlineExampleSetViewModel(this, x)).ToList();
        }
Exemple #3
0
        /// <summary>
        /// Converts the provided <see cref="SpecFlow.ScenarioOutline"/> instance into a <see cref="Augurk.Entities.Scenario"/> instance.
        /// </summary>
        /// <param name="scenarioOutline">The <see cref="SpecFlow.ScenarioOutline"/> instance that should be converted.</param>
        /// <returns>The converted <see cref="Augurk.Entities.Scenario"/> instance.</returns>
        public static Scenario ConvertToScenario(this SpecFlow.ScenarioOutline scenarioOutline)
        {
            if (scenarioOutline == null)
            {
                throw new ArgumentNullException("scenarioOutline");
            }

            return(new Scenario()
            {
                Title = scenarioOutline.Title,
                Description = scenarioOutline.Description,
                Tags = scenarioOutline.Tags.ConvertToStrings(),
                Steps = scenarioOutline.Steps.ConvertToSteps(),
                ExampleSets = scenarioOutline.Examples.ConvertToExampleSets()
            });
        }
Exemple #4
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()
            });
        }
        private ScenarioSteps CreateFirstExampleScenarioSteps(ScenarioOutline scenarioOutline)
        {
            foreach (var exampleSet in scenarioOutline.Examples.ExampleSets)
            {
                foreach (var example in exampleSet.Table.Body)
                {
                    Dictionary<string, string> paramSubst = new Dictionary<string, string>();
                    for (int i = 0; i < exampleSet.Table.Header.Cells.Length; i++)
                    {
                        paramSubst.Add(exampleSet.Table.Header.Cells[i].Value, example.Cells[i].Value);
                    }

                    return CreateScenarioSteps(scenarioOutline, paramSubst);
                }
            }
            return new ScenarioSteps();
        }
        private ScenarioSteps CreateScenarioSteps(ScenarioOutline scenarioOutline, Dictionary<string, string> paramSubst)
        {
            ScenarioSteps result = new ScenarioSteps();
            foreach (var scenarioStep in scenarioOutline.Steps)
            {
                var newStep = Clone(scenarioStep);
                newStep.Text = GetReplacedText(newStep.Text, paramSubst);
                newStep.MultiLineTextArgument = GetReplacedText(newStep.MultiLineTextArgument, paramSubst);

                if (newStep.TableArg != null)
                {
                    foreach (var row in newStep.TableArg.Body)
                    {
                        foreach (var cell in row.Cells)
                        {
                            cell.Value = GetReplacedText(cell.Value, paramSubst);
                        }
                    }
                }

                result.Add(newStep);
            }
            return result;
        }
    // $ANTLR end "scenarioKind"


    // $ANTLR start "scenarioOutline"
    // SpecFlowLangWalker.g:94:1: scenarioOutline returns [ScenarioOutline outline] : ^( SCENARIOOUTLINE (tags_= tags )? title_= text steps_= steps examples_= examples fp_= fileposition ) ;
    public ScenarioOutline scenarioOutline() // throws RecognitionException [1]
    {   
        ScenarioOutline outline = default(ScenarioOutline);

        Tags tags_ = default(Tags);

        Text title_ = default(Text);

        ScenarioSteps steps_ = default(ScenarioSteps);

        Examples examples_ = default(Examples);

        FilePosition fp_ = default(FilePosition);


        try 
    	{
            // SpecFlowLangWalker.g:99:5: ( ^( SCENARIOOUTLINE (tags_= tags )? title_= text steps_= steps examples_= examples fp_= fileposition ) )
            // SpecFlowLangWalker.g:99:9: ^( SCENARIOOUTLINE (tags_= tags )? title_= text steps_= steps examples_= examples fp_= fileposition )
            {
            	Match(input,SCENARIOOUTLINE,FOLLOW_SCENARIOOUTLINE_in_scenarioOutline614); 

            	Match(input, Token.DOWN, null); 
            	// SpecFlowLangWalker.g:100:18: (tags_= tags )?
            	int alt9 = 2;
            	int LA9_0 = input.LA(1);

            	if ( (LA9_0 == TAGS) )
            	{
            	    alt9 = 1;
            	}
            	switch (alt9) 
            	{
            	    case 1 :
            	        // SpecFlowLangWalker.g:100:18: tags_= tags
            	        {
            	        	PushFollow(FOLLOW_tags_in_scenarioOutline630);
            	        	tags_ = tags();
            	        	state.followingStackPointer--;


            	        }
            	        break;

            	}

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

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

            	PushFollow(FOLLOW_examples_in_scenarioOutline679);
            	examples_ = examples();
            	state.followingStackPointer--;

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


            	Match(input, Token.UP, null); 

            }


                outline =  new ScenarioOutline(title_, tags_, steps_, examples_);
                outline.FilePosition = fp_;

        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
        }
        finally 
    	{
        }
        return outline;
    }