How to use PickleStep class of Gherkin.CucumberMessages.Types package

Best Gherkin-dotnet code snippet using Gherkin.CucumberMessages.Types.PickleStep

PickleCompiler.cs

Source:PickleCompiler.cs Github

copy

Full Screen

...21 return pickles;22 }23 var language = feature.Language;24 var tags = feature.Tags;25 BuildFeature(pickles, language, tags, Enumerable.Empty<PickleStep>, feature.Children, gherkinDocument.Uri);26 return pickles;27 }28 protected virtual void BuildFeature(List<Pickle> pickles, string language, IEnumerable<Tag> tags,29 Func<IEnumerable<PickleStep>> backgroundStepsFactory, IEnumerable<FeatureChild> children,30 string gherkinDocumentUri) 31 {32 if (children == null)33 return;34 foreach (var child in children)35 {36 if (child.Background != null)37 {38 backgroundStepsFactory = BuildBackground(child.Background, backgroundStepsFactory);39 }40 else if (child.Rule != null)41 {42 var mergedRuleTags = tags.Concat(child.Rule.Tags);43 BuildRule(pickles, language, mergedRuleTags, backgroundStepsFactory, child.Rule.Children, gherkinDocumentUri);44 }45 else if (child.Scenario != null)46 {47 BuildScenario(pickles, language, tags, backgroundStepsFactory, gherkinDocumentUri, child.Scenario);48 }49 }50 }51 protected virtual void BuildRule(List<Pickle> pickles, string language, IEnumerable<Tag> tags,52 Func<IEnumerable<PickleStep>> backgroundStepsFactory, IEnumerable<RuleChild> children,53 string gherkinDocumentUri) 54 {55 if (children == null)56 return;57 foreach (var child in children)58 {59 if (child.Background != null)60 {61 backgroundStepsFactory = BuildBackground(child.Background, backgroundStepsFactory);62 }63 else if (child.Scenario != null)64 {65 BuildScenario(pickles, language, tags, backgroundStepsFactory, gherkinDocumentUri, child.Scenario);66 }67 }68 }69 private Func<IEnumerable<PickleStep>> BuildBackground(Background background, Func<IEnumerable<PickleStep>> backgroundStepsFactory)70 {71 var previousFactory = backgroundStepsFactory;72 backgroundStepsFactory = () => previousFactory().Concat(PickleSteps(background.Steps));73 return backgroundStepsFactory;74 }75 private void BuildScenario(List<Pickle> pickles, string language, IEnumerable<Tag> tags, Func<IEnumerable<PickleStep>> backgroundStepsFactory, string gherkinDocumentUri, Scenario scenario)76 {77 if (!scenario.Examples.Any())78 {79 CompileScenario(pickles, backgroundStepsFactory, scenario, tags, language, gherkinDocumentUri);80 }81 else82 {83 CompileScenarioOutline(pickles, backgroundStepsFactory, scenario, tags, language, gherkinDocumentUri);84 }85 }86 protected virtual void CompileScenario(List<Pickle> pickles,87 Func<IEnumerable<PickleStep>> backgroundStepsFactory, Scenario scenario, IEnumerable<Tag> featureTags,88 string language, string gherkinDocumentUri)89 {90 var steps = new List<PickleStep>();91 if (scenario.Steps.Any())92 steps.AddRange(backgroundStepsFactory());93 var scenarioTags = new List<Tag>();94 scenarioTags.AddRange(featureTags);95 scenarioTags.AddRange(scenario.Tags);96 steps.AddRange(PickleSteps(scenario.Steps));97 Pickle pickle = new Pickle(98 _idGenerator.GetNewId(),99 gherkinDocumentUri,100 scenario.Name,101 language,102 steps,103 PickleTags(scenarioTags),104 new []{ scenario.Id }105 );106 pickles.Add(pickle);107 }108 protected virtual void CompileScenarioOutline(List<Pickle> pickles,109 Func<IEnumerable<PickleStep>> backgroundStepsFactory, Scenario scenarioOutline,110 IEnumerable<Tag> featureTags, string language, string gherkinDocumentUri)111 {112 foreach (var examples in scenarioOutline.Examples)113 {114 if (examples.TableHeader == null) continue;115 var variableCells = examples.TableHeader.Cells;116 foreach (var values in examples.TableBody)117 {118 var valueCells = values.Cells;119 var steps = new List<PickleStep>();120 if (scenarioOutline.Steps.Any())121 steps.AddRange(backgroundStepsFactory());122 var tags = new List<Tag>();123 tags.AddRange(featureTags);124 tags.AddRange(scenarioOutline.Tags);125 tags.AddRange(examples.Tags);126 foreach(var scenarioOutlineStep in scenarioOutline.Steps)127 {128 string stepText = Interpolate(scenarioOutlineStep.Text, variableCells, valueCells);129 PickleStep pickleStep = CreatePickleStep(130 scenarioOutlineStep,131 stepText,132 CreatePickleArgument(scenarioOutlineStep, variableCells, valueCells),133 new[] { scenarioOutlineStep.Id, values.Id }134 );135 steps.Add(pickleStep);136 }137 Pickle pickle = new Pickle(138 _idGenerator.GetNewId(),139 gherkinDocumentUri,140 Interpolate(scenarioOutline.Name, variableCells, valueCells),141 language, 142 steps,143 PickleTags(tags),144 new[] { scenarioOutline.Id, values.Id }145 );146 pickles.Add(pickle);147 }148 }149 }150 protected virtual PickleStep CreatePickleStep(Step step, string text, PickleStepArgument argument, IEnumerable<string> astNodeIds)151 {152 return new PickleStep(argument, astNodeIds, _idGenerator.GetNewId(), text);153 }154 protected virtual PickleStepArgument CreatePickleArgument(Step argument)155 {156 var noCells = Enumerable.Empty<TableCell>();157 return CreatePickleArgument(argument, noCells, noCells);158 }159 protected virtual PickleStepArgument CreatePickleArgument(Step step, IEnumerable<TableCell> variableCells, IEnumerable<TableCell> valueCells)160 {161 if (step.DataTable != null) {162 var t = step.DataTable;163 var rows = t.Rows;164 var newRows = new List<PickleTableRow>(rows.Count());165 foreach(var row in rows)166 {167 var cells = row.Cells;168 var newCells = new List<PickleTableCell>();169 foreach(var cell in cells)170 {171 newCells.Add(172 new PickleTableCell(173 Interpolate(cell.Value, variableCells, valueCells)174 )175 );176 }177 newRows.Add(new PickleTableRow(newCells));178 }179 return new PickleStepArgument180 {181 DataTable = new PickleTable(newRows)182 };183 }184 if (step.DocString != null) {185 var ds = step.DocString;186 return187 new PickleStepArgument188 {189 DocString = new PickleDocString(190 Interpolate(ds.Content, variableCells, valueCells),191 ds.MediaType == null ? null : Interpolate(ds.MediaType, variableCells, valueCells))192 };193 } 194 195 return null;196 }197 protected virtual PickleStep[] PickleSteps(IEnumerable<Step> steps)198 {199 var result = new List<PickleStep>();200 foreach(var step in steps)201 {202 result.Add(PickleStep(step));203 }204 return result.ToArray();205 }206 protected virtual PickleStep PickleStep(Step step)207 {208 return CreatePickleStep(209 step,210 step.Text,211 CreatePickleArgument(step),212 new []{ step.Id }213 );214 }215 protected virtual string Interpolate(string name, IEnumerable<TableCell> variableCells, IEnumerable<TableCell> valueCells)216 {217 int col = 0;218 foreach (var variableCell in variableCells)219 {220 var valueCell = valueCells.ElementAt(col++);221 string header = variableCell.Value;222 string value = valueCell.Value;...

Full Screen

Full Screen

Pickle.cs

Source:Pickle.cs Github

copy

Full Screen

...12 public string Name { get; set; }13 [DataMember(Name = "language")]14 public string Language { get; set; }15 [DataMember(Name = "steps")]16 public IReadOnlyCollection<PickleStep> Steps { get; set; }17 [DataMember(Name = "tags")]18 public IReadOnlyCollection<PickleTag> Tags { get; set; }19 [DataMember(Name = "astNodeIds")]20 public IReadOnlyCollection<string> AstNodeIds { get; set; }21 public Pickle()22 {23 }24 25 public Pickle(string id, string uri, string name, string language, IEnumerable<PickleStep> steps, IEnumerable<PickleTag> tags, IEnumerable<string> astNodeIds)26 {27 Id = id;28 Uri = uri;29 Name = name;30 Language = language;31 Steps = steps.ToReadOnlyCollection();32 Tags = tags.ToReadOnlyCollection();33 AstNodeIds = astNodeIds.ToReadOnlyCollection();34 }35 }36}...

Full Screen

Full Screen

PickleStep.cs

Source:PickleStep.cs Github

copy

Full Screen

1using System.Collections.Generic;2using System.Runtime.Serialization;3namespace Gherkin.CucumberMessages.Types4{5 public class PickleStep6 {7 [DataMember(Name = "argument")]8 public PickleStepArgument Argument { get; set; }9 [DataMember(Name = "astNodeIds")]10 public IReadOnlyCollection<string> AstNodeIds { get; set; }11 [DataMember(Name = "id")]12 public string Id { get; set; }13 [DataMember(Name = "text")]14 public string Text { get; set; }15 public PickleStep()16 {17 }18 19 public PickleStep(PickleStepArgument argument, IEnumerable<string> astNodeIds, string id, string text)20 {21 Id = id;22 Text = text;23 Argument = argument;24 AstNodeIds = astNodeIds.ToReadOnlyCollection();25 }26 }27}

Full Screen

Full Screen

PickleStep

Using AI Code Generation

copy

Full Screen

1using System;2using System.IO;3using System.Linq;4using System.Collections.Generic;5using Gherkin;6using Gherkin.Ast;7using Gherkin.CucumberMessages.Types;8using Gherkin.Events.Args.Ast;9using Gherkin.Events.Args.Pickle;10using Gherkin.Events.Args.Source;11using Gherkin.Events.Messages;12using Gherkin.Parser;13{14 {15 public PickleStep(PickleLocation[] locations, string text, PickleStepArgument argument, string[] keyword)16 {17 Locations = locations;18 Text = text;19 Argument = argument;20 Keyword = keyword;21 }22 public PickleLocation[] Locations { get; }23 public string Text { get; }24 public PickleStepArgument Argument { get; }25 public string[] Keyword { get; }26 }27 {28 public PickleStepArgument(PickleTable table, PickleDocString docString)29 {30 Table = table;31 DocString = docString;32 }33 public PickleTable Table { get; }34 public PickleDocString DocString { get; }35 }36 {37 public PickleTable(PickleRow[] rows)38 {39 Rows = rows;40 }41 public PickleRow[] Rows { get; }42 }43 {44 public PickleDocString(PickleLocation location, string contentType, string content)45 {46 Location = location;47 ContentType = contentType;

Full Screen

Full Screen

PickleStep

Using AI Code Generation

copy

Full Screen

1using Gherkin.CucumberMessages.Types;2using Gherkin.CucumberMessages.Types;3using Gherkin.CucumberMessages.Types;4using Gherkin.CucumberMessages.Types;5using Gherkin.CucumberMessages.Types;6{7 {8 public static void Main()9 {10 PickleStep pickleStep = new PickleStep();11 PickleStepArgument pickleStepArgument = new PickleStepArgument();12 PickleTable pickleTable = new PickleTable();13 PickleString pickleString = new PickleString();14 PickleDocString pickleDocString = new PickleDocString();15 }16 }17}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gherkin-dotnet automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in PickleStep

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful