How to use Location method of Gherkin.Ast.Location class

Best Gherkin-dotnet code snippet using Gherkin.Ast.Location.Location

GherkinEntityExtensions.cs

Source:GherkinEntityExtensions.cs Github

copy

Full Screen

...45 Description = feature.Description,46 Tags = feature.Tags.ConvertToStrings(),47 Scenarios = scenarios.Select(scenario => scenario.ConvertToScenario(dialect)).ToArray(),48 Background = background?.ConvertToBackground(dialect),49 Location = feature.Location.ConvertToSourceLocation()50 };51 }52 /// <summary>53 /// Converts the provided <see cref="Gherkin.Ast.Location"/> instance into a <see cref="SourceLocation"/> instance.54 /// </summary>55 /// <param name="location">The <see cref="Gherkin.Ast.Location"/> instance that should be converted.</param>56 /// <returns>A <see cref="SourceLocation"/> instance containing the necessary data from the provided <paramref name="location"/>.</returns>57 public static SourceLocation ConvertToSourceLocation(this Gherkin.Ast.Location location)58 {59 if (location == null)60 {61 return null;62 }63 return new SourceLocation { Column = location.Column, Line = location.Line };64 }65 /// <summary>66 /// Converts the provided <see cref="Gherkin.Ast.Tag"/> instances into an enumerable collection of strings.67 /// </summary>68 /// <param name="tags">The <see cref="Gherkin.Ast.Tag"/> instances that should be converted.</param>69 /// <returns>An enumerable collection of strings.</returns>70 public static IEnumerable<string> ConvertToStrings(this IEnumerable<Gherkin.Ast.Tag> tags)71 {72 if (tags == null)73 {74 return new string[0];75 }76 // Strip the @ from the tagname (as it is provided now by the parser)77 return tags.Select(t => t.Name.Substring(1)).ToArray();78 }79 /// <summary>80 /// Converts the provided <see cref="Gherkin.Ast.Scenario"/> instance into a <see cref="Augurk.Entities.Scenario"/> instance.81 /// </summary>82 /// <param name="scenario">The <see cref="Gherkin.Ast.Scenario"/> instance that should be converted.</param>83 /// <param name="dialect">The <see cref="GherkinDialect"/> that is being used for this feature.</param>84 /// <returns>The converted <see cref="Augurk.Entities.Scenario"/> instance.</returns>85 public static Scenario ConvertToScenario(this Gherkin.Ast.Scenario scenario, GherkinDialect dialect)86 {87 if (scenario == null)88 {89 throw new ArgumentNullException(nameof(scenario));90 }91 return new Scenario()92 {93 Title = scenario.Name,94 Description = scenario.Description,95 Tags = scenario.Tags.ConvertToStrings(),96 Steps = scenario.Steps.ConvertToSteps(dialect),97 ExampleSets = scenario.Examples.ConvertToExampleSets(),98 Location = scenario.Location.ConvertToSourceLocation()99 };100 }101 /// <summary>102 /// Converts the provided <see cref=" Gherkin.Ast.Background"/> instance into a <see cref="Augurk.Entities.Background"/> instance.103 /// </summary>104 /// <param name="background">The <see cref=" Gherkin.Ast.Background"/> instance that should be converted.</param>105 /// <param name="dialect">The <see cref="GherkinDialect"/> that is being used for this feature.</param>106 /// <returns>The converted <see cref="Augurk.Entities.Background"/> instance.</returns>107 public static Background ConvertToBackground(this Gherkin.Ast.Background background, GherkinDialect dialect)108 {109 if (background == null)110 {111 return null;112 }113 return new Background()114 {115 Title = background.Name,116 Keyword = background.Keyword,117 Steps = background.Steps.ConvertToSteps(dialect),118 Location = background.Location.ConvertToSourceLocation()119 };120 }121 /// <summary>122 /// Converts the provided <see cref="Gherkin.Ast.Examples"/> instances into an enumerable collection of <see cref="Augurk.Entities.ExampleSet"/> instances.123 /// </summary>124 /// <param name="examples">The <see cref="Gherkin.Ast.Examples"/> instances that should be converted.</param>125 /// <returns>An enumerable collection of <see cref="Augurk.Entities.ExampleSet"/> instances.</returns>126 public static IEnumerable<ExampleSet> ConvertToExampleSets(this IEnumerable<Gherkin.Ast.Examples> examples)127 {128 if (examples == null)129 {130 throw new ArgumentNullException("examples");131 }132 return examples.Select(exampleSet => exampleSet.ConvertToExampleSet()).ToArray();133 }134 /// <summary>135 /// Converts the provided <see cref="Gherkin.Ast.Examples"/> instance into a<see cref="Augurk.Entities.ExampleSet"/> instance.136 /// </summary>137 /// <param name="examples">The <see cref="Gherkin.Ast.Examples"/> instance that should be converted.</param>138 /// <returns>The converted <see cref="Augurk.Entities.ExampleSet"/> instance.</returns>139 public static ExampleSet ConvertToExampleSet(this Gherkin.Ast.Examples examples)140 {141 if (examples == null)142 {143 throw new ArgumentNullException("exampleSet");144 }145 return new ExampleSet()146 {147 Title = examples.Name,148 Description = examples.Description,149 Keyword = examples.Keyword,150 Tags = examples.Tags.ConvertToStrings(),151 Columns = examples.TableHeader.Cells.Select(cell => cell.Value).ToArray(),152 Rows = examples.TableBody.Select(row => row.Cells.Select(cell => cell.Value).ToArray()).ToArray(),153 Location = examples.Location.ConvertToSourceLocation()154 };155 }156 /// <summary>157 /// Converts the provided <see cref="Gherkin.Ast.Step"/> instances into an enumerable collection of <see cref="Augurk.Entities.Step"/> instances.158 /// </summary>159 /// <param name="steps">The <see cref="Gherkin.Ast.Step"/> instances that should be converted.</param>160 /// <param name="dialect">The <see cref="GherkinDialect"/> that is being used for this feature.</param>161 /// <returns>An enumerable collection of <see cref="Augurk.Entities.Step"/> instances.</returns>162 public static IEnumerable<Step> ConvertToSteps(this IEnumerable<Gherkin.Ast.Step> steps, GherkinDialect dialect)163 {164 if (steps == null)165 {166 return new Step[0];167 }168 BlockKeyword? blockKeyword = null;169 var result = new List<Step>();170 foreach (var step in steps)171 {172 var convertedStep = step.ConvertToStep(dialect);173 if (convertedStep.StepKeyword != StepKeyword.And && convertedStep.StepKeyword != StepKeyword.But)174 {175 switch (convertedStep.StepKeyword)176 {177 case StepKeyword.Given:178 blockKeyword = BlockKeyword.Given;179 break;180 case StepKeyword.When:181 blockKeyword = BlockKeyword.When;182 break;183 case StepKeyword.Then:184 blockKeyword = BlockKeyword.Then;185 break;186 default:187 throw new NotSupportedException($"Unexpected step keyword {convertedStep.StepKeyword}.");188 }189 }190 if (blockKeyword == null)191 {192 throw new NotSupportedException($"Detected incorrect use of Gherkin syntax. Scenario cannot start with And or But ('{step.Keyword}').");193 }194 convertedStep.BlockKeyword = blockKeyword.Value;195 result.Add(convertedStep);196 }197 return result;198 }199 /// <summary>200 /// Converts the provided <see cref="Gherkin.Ast.Step"/> instance into a <see cref="Augurk.Entities.Step"/> instance.201 /// </summary>202 /// <param name="step">The <see cref="Gherkin.Ast.Step"/> instance that should be converted.</param>203 /// <param name="blockKeyword">Current block of keywords being converted.</param>204 /// <param name="dialect">The <see cref="GherkinDialect"/> that is being used for this feature.</param>205 /// <returns>The converted <see cref="Augurk.Entities.Step"/> instance.</returns>206 public static Step ConvertToStep(this Gherkin.Ast.Step step, GherkinDialect dialect)207 {208 if (step == null)209 {210 throw new ArgumentNullException("step");211 }212 return new Step()213 {214 StepKeyword = step.Keyword.ConvertToStepKeyword(dialect),215 Keyword = step.Keyword,216 Content = step.Text,217 TableArgument = step.Argument.ConvertToTable(),218 Location = step.Location.ConvertToSourceLocation()219 };220 }221 /// <summary>222 /// Converts the provided <see cref="Gherkin.StepKeyword"/> into a <see cref="Augurk.Entities.StepKeyword"/>.223 /// </summary>224 /// <param name="stepKeyword">The <see cref="Gherkin.StepKeyword"/> that should be converted.</param>225 /// <param name="dialect">The <see cref="GherkinDialect"/> that is being used for this feature.</param>226 /// <returns>The converted <see cref="Augurk.Entities.StepKeyword"/>.</returns>227 public static StepKeyword ConvertToStepKeyword(this string stepKeyword, GherkinDialect dialect)228 {229 if (dialect.AndStepKeywords.Contains(stepKeyword))230 {231 return StepKeyword.And;232 }233 else if (dialect.ButStepKeywords.Contains(stepKeyword))234 {235 return StepKeyword.But;236 }237 else if (dialect.GivenStepKeywords.Contains(stepKeyword))238 {239 return StepKeyword.Given;240 }241 else if (dialect.WhenStepKeywords.Contains(stepKeyword))242 {243 return StepKeyword.When;244 }245 else if (dialect.ThenStepKeywords.Contains(stepKeyword))246 {247 return StepKeyword.Then;248 }249 else250 {251 return StepKeyword.None;252 }253 }254 /// <summary>255 /// Converts the provided <see cref="Gherkin.Ast.StepArgument"/> instance into a <see cref="Augurk.Entities.Table"/> instance.256 /// </summary>257 /// <param name="table">The <see cref="Gherkin.Ast.StepArgument"/> instance that should be converted.</param>258 /// <returns>The converted <see cref="Augurk.Entities.Table"/> instanc, or <c>null</c> if the provided <paramref name="argument"/> is not a <see cref="Gherkin.Ast.DataTable"/>.</returns>259 public static Table ConvertToTable(this Gherkin.Ast.StepArgument argument)260 {261 Gherkin.Ast.DataTable table = argument as Gherkin.Ast.DataTable;262 if (table == null)263 {264 return null;265 }266 return new Table267 {268 Columns = table.Rows.FirstOrDefault()?.Cells.Select(cell => cell.Value).ToArray(),269 // Skip the first row as those are the headers270 Rows = table.Rows.Skip(1).Select(row => row.Cells.Select(cell => cell.Value).ToArray()).ToArray(),271 Location = table.Location.ConvertToSourceLocation()272 };273 }274 }275}...

Full Screen

Full Screen

AstBuilder.cs

Source:AstBuilder.cs Github

copy

Full Screen

...26 public void Build(Token token)27 {28 if (token.MatchedType == TokenType.Comment)29 {30 comments.Add(CreateComment(GetLocation(token), token.MatchedText));31 }32 else33 {34 CurrentNode.Add((RuleType) token.MatchedType, token);35 }36 }3738 public void StartRule(RuleType ruleType)39 {40 stack.Push(new AstNode(ruleType));41 }4243 public void EndRule(RuleType ruleType)44 {45 var node = stack.Pop();46 object transformedNode = GetTransformedNode(node);47 CurrentNode.Add(node.RuleType, transformedNode);48 }4950 public T GetResult()51 {52 return CurrentNode.GetSingle<T>(RuleType.GherkinDocument);53 }5455 private object GetTransformedNode(AstNode node)56 {57 switch (node.RuleType)58 {59 case RuleType.Step:60 {61 var stepLine = node.GetToken(TokenType.StepLine);62 var stepArg = node.GetSingle<StepArgument>(RuleType.DataTable) ??63 node.GetSingle<StepArgument>(RuleType.DocString) ??64 null; // empty arg65 return CreateStep(GetLocation(stepLine), stepLine.MatchedKeyword, stepLine.MatchedText, stepArg, node);66 }67 case RuleType.DocString:68 {69 var separatorToken = node.GetTokens(TokenType.DocStringSeparator).First();70 var contentType = separatorToken.MatchedText.Length == 0 ? null : separatorToken.MatchedText;71 var lineTokens = node.GetTokens(TokenType.Other);72 var content = string.Join(Environment.NewLine, lineTokens.Select(lt => lt.MatchedText));7374 return CreateDocString(GetLocation(separatorToken), contentType, content, node);75 }76 case RuleType.DataTable:77 {78 var rows = GetTableRows(node);79 return CreateDataTable(rows, node);80 }81 case RuleType.Background:82 {83 var backgroundLine = node.GetToken(TokenType.BackgroundLine);84 var description = GetDescription(node);85 var steps = GetSteps(node);86 return CreateBackground(GetLocation(backgroundLine), backgroundLine.MatchedKeyword, backgroundLine.MatchedText, description, steps, node);87 }88 case RuleType.ScenarioDefinition:89 {90 var tags = GetTags(node);9192 var scenarioNode = node.GetSingle<AstNode>(RuleType.Scenario);93 var scenarioLine = scenarioNode.GetToken(TokenType.ScenarioLine);9495 var description = GetDescription(scenarioNode);96 var steps = GetSteps(scenarioNode);97 var examples = scenarioNode.GetItems<Examples>(RuleType.ExamplesDefinition).ToArray();98 return CreateScenario(tags, GetLocation(scenarioLine), scenarioLine.MatchedKeyword, scenarioLine.MatchedText, description, steps, examples, node);99 }100 case RuleType.ExamplesDefinition:101 {102 var tags = GetTags(node);103 var examplesNode = node.GetSingle<AstNode>(RuleType.Examples);104 var examplesLine = examplesNode.GetToken(TokenType.ExamplesLine);105 var description = GetDescription(examplesNode);106107 var allRows = examplesNode.GetSingle<TableRow[]>(RuleType.ExamplesTable);108 var header = allRows != null ? allRows.First() : null;109 var rows = allRows != null ? allRows.Skip(1).ToArray() : null;110 return CreateExamples(tags, GetLocation(examplesLine), examplesLine.MatchedKeyword, examplesLine.MatchedText, description, header, rows, node);111 }112 case RuleType.ExamplesTable:113 {114 return GetTableRows(node);115 }116 case RuleType.Description:117 {118 var lineTokens = node.GetTokens(TokenType.Other);119120 // Trim trailing empty lines121 lineTokens = lineTokens.Reverse().SkipWhile(t => string.IsNullOrWhiteSpace(t.MatchedText)).Reverse();122123 return string.Join(Environment.NewLine, lineTokens.Select(lt => lt.MatchedText));124 }125 case RuleType.Feature:126 {127 var header = node.GetSingle<AstNode>(RuleType.FeatureHeader);128 if(header == null) return null;129 var tags = GetTags(header);130 var featureLine = header.GetToken(TokenType.FeatureLine);131 if(featureLine == null) return null;132 var children = new List<IHasLocation> ();133 var background = node.GetSingle<Background>(RuleType.Background);134 if (background != null) 135 {136 children.Add (background);137 }138 var childrenEnumerable = children.Concat(node.GetItems<IHasLocation>(RuleType.ScenarioDefinition))139 .Concat(node.GetItems<IHasLocation>(RuleType.Rule));140 var description = GetDescription(header);141 if(featureLine.MatchedGherkinDialect == null) return null;142 var language = featureLine.MatchedGherkinDialect.Language;143144 return CreateFeature(tags, GetLocation(featureLine), language, featureLine.MatchedKeyword, featureLine.MatchedText, description, childrenEnumerable.ToArray(), node);145 }146 case RuleType.Rule:147 {148 var header = node.GetSingle<AstNode>(RuleType.RuleHeader);149 if (header == null) return null;150 var ruleLine = header.GetToken(TokenType.RuleLine);151 if (ruleLine == null) return null;152 var children = new List<IHasLocation>();153 var background = node.GetSingle<Background>(RuleType.Background);154 if (background != null)155 {156 children.Add(background);157 }158 var childrenEnumerable = children.Concat(node.GetItems<IHasLocation>(RuleType.ScenarioDefinition));159 var description = GetDescription(header);160 if (ruleLine.MatchedGherkinDialect == null) return null;161 var language = ruleLine.MatchedGherkinDialect.Language;162163 return CreateRule(GetLocation(ruleLine), ruleLine.MatchedKeyword, ruleLine.MatchedText, description, childrenEnumerable.ToArray(), node);164 }165 case RuleType.GherkinDocument:166 {167 var feature = node.GetSingle<Feature>(RuleType.Feature);168169 return CreateGherkinDocument(feature, comments.ToArray(), node);170 }171 }172173 return node;174 }175176 protected virtual Background CreateBackground(Location location, string keyword, string name, string description, Step[] steps, AstNode node)177 {178 return new Background(location, keyword, name, description, steps);179 }180181 protected virtual DataTable CreateDataTable(TableRow[] rows, AstNode node)182 {183 return new DataTable(rows);184 }185186 protected virtual Comment CreateComment(Location location, string text)187 {188 return new Comment(location, text);189 }190191 protected virtual Examples CreateExamples(Tag[] tags, Location location, string keyword, string name, string description, TableRow header, TableRow[] body, AstNode node)192 {193 return new Examples(tags, location, keyword, name, description, header, body);194 }195196 protected virtual Scenario CreateScenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples, AstNode node)197 {198 return new Scenario(tags, location, keyword, name, description, steps, examples);199 }200201 protected virtual DocString CreateDocString(Location location, string contentType, string content, AstNode node)202 {203 return new DocString(location, contentType, content);204 }205206 protected virtual Step CreateStep(Location location, string keyword, string text, StepArgument argument, AstNode node)207 {208 return new Step(location, keyword, text, argument);209 }210211 protected virtual GherkinDocument CreateGherkinDocument(Feature feature, Comment[] gherkinDocumentComments, AstNode node) {212 return new GherkinDocument(feature, gherkinDocumentComments);213 }214215 protected virtual Feature CreateFeature(Tag[] tags, Location location, string language, string keyword, string name, string description, IHasLocation[] children, AstNode node)216 {217 return new Feature(tags, location, language, keyword, name, description, children);218 }219220 protected virtual Rule CreateRule(Location location, string keyword, string name, string description, IHasLocation[] children, AstNode node)221 {222 return new Rule(location, keyword, name, description, children);223 }224225 protected virtual Tag CreateTag(Location location, string name, AstNode node)226 {227 return new Tag(location, name);228 }229230 protected virtual Location CreateLocation(int line, int column)231 {232 return new Location(line, column);233 }234235 protected virtual TableRow CreateTableRow(Location location, TableCell[] cells, AstNode node)236 {237 return new TableRow(location, cells);238 }239240 protected virtual TableCell CreateTableCell(Location location, string value)241 {242 return new TableCell(location, value);243 }244245 private Location GetLocation(Token token, int column = 0)246 {247 return column == 0 ? token.Location : CreateLocation(token.Location.Line, column);248 }249250 private Tag[] GetTags(AstNode node)251 {252 var tagsNode = node.GetSingle<AstNode>(RuleType.Tags);253 if (tagsNode == null)254 return new Tag[0];255256 return tagsNode.GetTokens(TokenType.TagLine)257 .SelectMany(t => t.MatchedItems, (t, tagItem) =>258 CreateTag(GetLocation(t, tagItem.Column), tagItem.Text, tagsNode))259 .ToArray();260 }261262 private TableRow[] GetTableRows(AstNode node)263 {264 var rows = node.GetTokens(TokenType.TableRow).Select(token => CreateTableRow(GetLocation(token), GetCells(token), node)).ToArray();265 CheckCellCountConsistency(rows);266 return rows;267 }268269 protected virtual void CheckCellCountConsistency(TableRow[] rows)270 {271 if (rows.Length == 0)272 return;273274 int cellCount = rows[0].Cells.Count();275 foreach (var row in rows)276 {277 if (row.Cells.Count() != cellCount)278 {279 HandleAstError("inconsistent cell count within the table", row.Location);280 }281 }282 }283284 protected virtual void HandleAstError(string message, Location location)285 {286 throw new AstBuilderException(message, location);287 }288289 private TableCell[] GetCells(Token tableRowToken)290 {291 return tableRowToken.MatchedItems292 .Select(cellItem => CreateTableCell(GetLocation(tableRowToken, cellItem.Column), cellItem.Text))293 .ToArray();294 }295296 private static Step[] GetSteps(AstNode scenarioDefinitionNode)297 {298 return scenarioDefinitionNode.GetItems<Step>(RuleType.Step).ToArray();299 }300301 private static string GetDescription(AstNode scenarioDefinitionNode)302 {303 return scenarioDefinitionNode.GetSingle<string>(RuleType.Description);304 }305 }306} ...

Full Screen

Full Screen

AstMessagesConverter.cs

Source:AstMessagesConverter.cs Github

copy

Full Screen

...6using Background = Gherkin.CucumberMessages.Types.Background;7using Comment = Gherkin.CucumberMessages.Types.Comment;8using Examples = Gherkin.CucumberMessages.Types.Examples;9using Feature = Gherkin.CucumberMessages.Types.Feature;10using Location = Gherkin.CucumberMessages.Types.Location;11using Rule = Gherkin.CucumberMessages.Types.Rule;12using Step = Gherkin.CucumberMessages.Types.Step;13using DataTable = Gherkin.CucumberMessages.Types.DataTable;14using DocString = Gherkin.CucumberMessages.Types.DocString;15using GherkinDocument = Gherkin.CucumberMessages.Types.GherkinDocument;16using Scenario = Gherkin.CucumberMessages.Types.Scenario;17using TableCell = Gherkin.CucumberMessages.Types.TableCell;18using TableRow = Gherkin.CucumberMessages.Types.TableRow;19using Tag = Gherkin.CucumberMessages.Types.Tag;20namespace Gherkin.CucumberMessages21{22 public class AstMessagesConverter23 {24 private readonly IIdGenerator _idGenerator;25 public AstMessagesConverter(IIdGenerator idGenerator)26 {27 _idGenerator = idGenerator;28 }29 public GherkinDocument ConvertGherkinDocumentToEventArgs(Ast.GherkinDocument gherkinDocument, string sourceEventUri)30 {31 return new GherkinDocument()32 {33 Uri = sourceEventUri,34 Feature = ConvertFeature(gherkinDocument),35 Comments = ConvertComments(gherkinDocument)36 };37 }38 private IReadOnlyCollection<Comment> ConvertComments(Ast.GherkinDocument gherkinDocument)39 {40 return gherkinDocument.Comments.Select(c =>41 new Comment()42 {43 Text = c.Text,44 Location = ConvertLocation(c.Location)45 }).ToReadOnlyCollection();46 }47 private Feature ConvertFeature(Ast.GherkinDocument gherkinDocument)48 {49 var feature = gherkinDocument.Feature;50 if (feature == null)51 {52 return null;53 }54 var children = feature.Children.Select(ConvertToFeatureChild).ToReadOnlyCollection();55 var tags = feature.Tags.Select(ConvertTag).ToReadOnlyCollection();56 return new Feature()57 {58 Name = CucumberMessagesDefaults.UseDefault(feature.Name, CucumberMessagesDefaults.DefaultName),59 Description = CucumberMessagesDefaults.UseDefault(feature.Description, CucumberMessagesDefaults.DefaultDescription),60 Keyword = feature.Keyword,61 Language = feature.Language,62 Location = ConvertLocation(feature.Location),63 Children = children,64 Tags = tags65 };66 }67 private static Location ConvertLocation(Ast.Location location)68 {69 return new Location(location.Column, location.Line);70 }71 private FeatureChild ConvertToFeatureChild(IHasLocation hasLocation)72 {73 var tuple = ConvertToChild(hasLocation);74 return new FeatureChild(tuple.Item3, tuple.Item1, tuple.Item2);75 }76 77 private RuleChild ConvertToRuleChild(IHasLocation hasLocation)78 {79 var tuple = ConvertToChild(hasLocation);80 return new RuleChild(tuple.Item1, tuple.Item3);81 }82 83 private Tuple<Background, Rule, Scenario> ConvertToChild(IHasLocation hasLocation)84 {85 switch (hasLocation)86 {87 case Gherkin.Ast.Background background:88 var backgroundSteps = background.Steps.Select(ConvertStep).ToList();89 return new Tuple<Background, Rule, Scenario>(new Background90 {91 Id = _idGenerator.GetNewId(),92 Location = ConvertLocation(background.Location),93 Name = CucumberMessagesDefaults.UseDefault(background.Name, CucumberMessagesDefaults.DefaultName),94 Description = CucumberMessagesDefaults.UseDefault(background.Description, CucumberMessagesDefaults.DefaultDescription),95 Keyword = background.Keyword,96 Steps = backgroundSteps97 }, null, null);98 case Ast.Scenario scenario:99 var steps = scenario.Steps.Select(ConvertStep).ToList();100 var examples = scenario.Examples.Select(ConvertExamples).ToReadOnlyCollection();101 var tags = scenario.Tags.Select(ConvertTag).ToReadOnlyCollection();102 return new Tuple<Background, Rule, Scenario>(null, null, new Scenario()103 {104 Id = _idGenerator.GetNewId(),105 Keyword = scenario.Keyword,106 Location = ConvertLocation(scenario.Location),107 Name = CucumberMessagesDefaults.UseDefault(scenario.Name, CucumberMessagesDefaults.DefaultName),108 Description = CucumberMessagesDefaults.UseDefault(scenario.Description, CucumberMessagesDefaults.DefaultDescription),109 Steps = steps,110 Examples = examples,111 Tags = tags112 });113 case Ast.Rule rule:114 {115 var ruleChildren = rule.Children.Select(ConvertToRuleChild).ToReadOnlyCollection();116 var ruleTags = rule.Tags.Select(ConvertTag).ToReadOnlyCollection();117 return new Tuple<Background, Rule, Scenario>(null, new Rule118 {119 Id = _idGenerator.GetNewId(),120 Name = CucumberMessagesDefaults.UseDefault(rule.Name, CucumberMessagesDefaults.DefaultName),121 Description = CucumberMessagesDefaults.UseDefault(rule.Description, CucumberMessagesDefaults.DefaultDescription),122 Keyword = rule.Keyword,123 Children = ruleChildren,124 Location = ConvertLocation(rule.Location),125 Tags = ruleTags126 }, null);127 }128 default:129 throw new NotImplementedException();130 }131 }132 private Examples ConvertExamples(Ast.Examples examples)133 {134 var header = ConvertTableHeader(examples);135 var body = ConvertToTableBody(examples);136 var tags = examples.Tags.Select(ConvertTag).ToReadOnlyCollection();137 return new Examples()138 {139 Id = _idGenerator.GetNewId(),140 Name = CucumberMessagesDefaults.UseDefault(examples.Name, CucumberMessagesDefaults.DefaultName),141 Keyword = examples.Keyword,142 Description = CucumberMessagesDefaults.UseDefault(examples.Description, CucumberMessagesDefaults.DefaultDescription),143 Location = ConvertLocation(examples.Location),144 TableHeader = header,145 TableBody = body,146 Tags = tags147 };148 }149 private IReadOnlyCollection<TableRow> ConvertToTableBody(Ast.Examples examples)150 {151 if (examples.TableBody == null)152 return new List<TableRow>();153 return ConvertToTableRow(examples.TableBody);154 }155 private IReadOnlyCollection<TableRow> ConvertToTableRow(IEnumerable<Gherkin.Ast.TableRow> rows)156 {157 return rows.Select(b =>158 new TableRow159 {160 Id = _idGenerator.GetNewId(),161 Location = ConvertLocation(b.Location),162 Cells = b.Cells.Select(ConvertCell).ToReadOnlyCollection()163 }).ToReadOnlyCollection();164 }165 private TableRow ConvertTableHeader(Ast.Examples examples)166 {167 if (examples.TableHeader == null)168 return null;169 return new TableRow170 {171 Id = _idGenerator.GetNewId(),172 Location = ConvertLocation(examples.TableHeader.Location),173 Cells = examples.TableHeader.Cells.Select(ConvertCell).ToReadOnlyCollection()174 };175 }176 private Tag ConvertTag(Ast.Tag tag)177 {178 return new Tag179 {180 Id = _idGenerator.GetNewId(),181 Location = ConvertLocation(tag.Location),182 Name = tag.Name183 };184 }185 private TableCell ConvertCell(Ast.TableCell c)186 {187 return new TableCell()188 {189 Value = CucumberMessagesDefaults.UseDefault(c.Value, CucumberMessagesDefaults.DefaultCellValue),190 Location = ConvertLocation(c.Location)191 };192 }193 private Step ConvertStep(Ast.Step step)194 {195 DataTable dataTable = null;196 if (step.Argument is Gherkin.Ast.DataTable astDataTable) 197 {198 var rows = ConvertToTableRow(astDataTable.Rows);199 dataTable = new DataTable200 {201 Rows = rows,202 Location = ConvertLocation(astDataTable.Location)203 };204 }205 DocString docString = null;206 if (step.Argument is Gherkin.Ast.DocString astDocString) 207 {208 docString = new DocString209 {210 Content = astDocString.Content,211 MediaType = astDocString.ContentType,212 Delimiter = astDocString.Delimiter ?? "\"\"\"", //TODO: store DocString delimiter in Gherkin AST213 Location = ConvertLocation(astDocString.Location)214 };215 }216 return new Step()217 {218 Id = _idGenerator.GetNewId(),219 Keyword = step.Keyword,220 Text = step.Text,221 DataTable = dataTable,222 DocString = docString,223 Location = ConvertLocation(step.Location)224 };225 }226 }227}...

Full Screen

Full Screen

CompatibleAstConverter.cs

Source:CompatibleAstConverter.cs Github

copy

Full Screen

...23 ConvertToCompatibleBackground(specFlowFeature.Background), 24 ConvertToCompatibleScenarios(specFlowFeature.ScenarioDefinitions), 25 ConvertToCompatibleComments(specFlowDocument.Comments))26 {27 FilePosition = ConvertToCompatibleFilePosition(specFlowFeature.Location),28 Language = specFlowFeature.Language,29 SourceFile = specFlowDocument.SourceFilePath30 };31 }32 private static Comment[] ConvertToCompatibleComments(IEnumerable<global::Gherkin.Ast.Comment> comments)33 {34 return comments.Select(ConvertToCompatibleComment).Where(c => c != null).ToArray();35 }36 private static Comment ConvertToCompatibleComment(global::Gherkin.Ast.Comment c)37 {38 var trimmedText = c.Text.TrimStart('#', ' ', '\t');39 if (trimmedText.Length == 0)40 return null;41 return new Comment(trimmedText, ConvertToCompatibleFilePosition(c.Location, c.Text.Length - trimmedText.Length));42 }43 private static Scenario[] ConvertToCompatibleScenarios(IEnumerable<Gherkin.Ast.ScenarioDefinition> scenarioDefinitions)44 {45 return scenarioDefinitions.Select(ConvertToCompatibleScenario).ToArray();46 }47 private static Scenario ConvertToCompatibleScenario(Gherkin.Ast.ScenarioDefinition sd)48 {49 var convertToCompatibleTags = ConvertToCompatibleTags(sd.GetTags());50 var result = sd is global::Gherkin.Ast.ScenarioOutline51 ? new ScenarioOutline(sd.Keyword, sd.Name, sd.Description, convertToCompatibleTags, ConvertToCompatibleSteps(sd.Steps), ConvertToCompatibleExamples(((global::Gherkin.Ast.ScenarioOutline)sd).Examples))52 : new Scenario(sd.Keyword, sd.Name, sd.Description, convertToCompatibleTags, ConvertToCompatibleSteps(sd.Steps));53 result.FilePosition = ConvertToCompatibleFilePosition(sd.Location);54 return result;55 }56 private static Examples ConvertToCompatibleExamples(IEnumerable<global::Gherkin.Ast.Examples> examples)57 {58 return new Examples(examples.Select(e => new ExampleSet(e.Keyword, e.Name, e.Description, ConvertToCompatibleTags(e.Tags), ConvertToCompatibleExamplesTable(e))).ToArray());59 }60 private static GherkinTable ConvertToCompatibleExamplesTable(global::Gherkin.Ast.Examples examples)61 {62 return new GherkinTable(ConvertToCompatibleRow(examples.TableHeader), examples.TableBody.Select(ConvertToCompatibleRow).ToArray());63 }64 private static GherkinTableRow ConvertToCompatibleRow(global::Gherkin.Ast.TableRow tableRow)65 {66 return new GherkinTableRow(tableRow.Cells.Select(c => new GherkinTableCell(c.Value)).ToArray())67 {68 FilePosition = ConvertToCompatibleFilePosition(tableRow.Location)69 };70 }71 private static ScenarioSteps ConvertToCompatibleSteps(IEnumerable<global::Gherkin.Ast.Step> steps)72 {73 return new ScenarioSteps(steps.Select(s => ConvertToCompatibleStep((SpecFlowStep)s)).ToArray());74 }75 private static ScenarioStep ConvertToCompatibleStep(SpecFlowStep step)76 {77 ScenarioStep result = null;78 if (step.StepKeyword == StepKeyword.Given)79 result = new Given {StepKeyword = step.StepKeyword };80 else if (step.StepKeyword == StepKeyword.When)81 result = new When {StepKeyword = step.StepKeyword };82 else if (step.StepKeyword == StepKeyword.Then)83 result = new Then {StepKeyword = step.StepKeyword };84 else if (step.StepKeyword == StepKeyword.And)85 result = new And { StepKeyword = step.StepKeyword };86 else if (step.StepKeyword == StepKeyword.But)87 result = new But {StepKeyword = step.StepKeyword };88 if (result == null)89 throw new NotSupportedException();90 result.Keyword = step.Keyword;91 result.Text = step.Text;92 result.ScenarioBlock = step.ScenarioBlock;93 result.MultiLineTextArgument = step.Argument is global::Gherkin.Ast.DocString ? ((global::Gherkin.Ast.DocString) step.Argument).Content : null;94 result.TableArg = step.Argument is global::Gherkin.Ast.DataTable ? ConvertToCompatibleTable(((global::Gherkin.Ast.DataTable) step.Argument).Rows) : null;95 result.FilePosition = ConvertToCompatibleFilePosition(step.Location);96 return result;97 }98 private static FilePosition ConvertToCompatibleFilePosition(global::Gherkin.Ast.Location location, int columnDiff = 0)99 {100 if (location == null)101 return null;102 return new FilePosition(location.Line, location.Column + columnDiff);103 }104 private static GherkinTable ConvertToCompatibleTable(IEnumerable<global::Gherkin.Ast.TableRow> rows)105 {106 var rowsArray = rows.ToArray();107 return new GherkinTable(ConvertToCompatibleRow(rowsArray.First()), rowsArray.Skip(1).Select(ConvertToCompatibleRow).ToArray());108 }109 private static Background ConvertToCompatibleBackground(global::Gherkin.Ast.Background background)110 {111 if (background == null)112 return null;113 return new Background(background.Keyword, background.Name, background.Description, ConvertToCompatibleSteps(background.Steps))114 {115 FilePosition = ConvertToCompatibleFilePosition(background.Location)116 };117 }118 private static Tags ConvertToCompatibleTags(IEnumerable<global::Gherkin.Ast.Tag> tags)119 {120 if (tags == null || !tags.Any())121 return null;122 return new Tags(tags.Select(t => new Tag(t.GetNameWithoutAt())).ToArray());123 }124 }125}...

Full Screen

Full Screen

SpecFlowGherkinParser.cs

Source:SpecFlowGherkinParser.cs Github

copy

Full Screen

...52 }5354 private class SpecFlowAstBuilder : AstBuilder<SpecFlowDocument>55 {56 private readonly SpecFlowDocumentLocation documentLocation;57 private ScenarioBlock scenarioBlock = ScenarioBlock.Given;5859 public SpecFlowAstBuilder(SpecFlowDocumentLocation documentLocation)60 {61 this.documentLocation = documentLocation;62 }6364 protected override Feature CreateFeature(Tag[] tags, Location location, string language, string keyword, string name, string description, IHasLocation[] children, AstNode node)65 {66 return new SpecFlowFeature(tags, location, language, keyword, name, description, children);67 }6869 protected override Scenario CreateScenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples, AstNode node)70 {71 ResetBlock();7273 if (examples != null && examples.Length > 0)74 {75 return new ScenarioOutline(tags, location, keyword, name, description, steps, examples);76 }7778 return base.CreateScenario(tags, location, keyword, name, description, steps, examples, node);7980 }8182 protected override Step CreateStep(Location location, string keyword, string text, StepArgument argument, AstNode node)83 {84 var token = node.GetToken(TokenType.StepLine);85 var stepKeyword = GetStepKeyword(token.MatchedGherkinDialect, keyword);86 scenarioBlock = stepKeyword.ToScenarioBlock() ?? scenarioBlock;8788 return new SpecFlowStep(location, keyword, text, argument, stepKeyword, scenarioBlock);89 }9091 private void ResetBlock()92 {93 scenarioBlock = ScenarioBlock.Given;94 }9596 protected override GherkinDocument CreateGherkinDocument(Feature feature, Comment[] gherkinDocumentComments, AstNode node)97 {98 return new SpecFlowDocument((SpecFlowFeature)feature, gherkinDocumentComments, documentLocation);99 }100101 protected override Background CreateBackground(Location location, string keyword, string name, string description, Step[] steps, AstNode node)102 {103 ResetBlock();104 return base.CreateBackground(location, keyword, name, description, steps, node);105 }106 }107108 public SpecFlowDocument Parse(TextReader featureFileReader, SpecFlowDocumentLocation documentLocation)109 {110 var parser = new Parser<SpecFlowDocument>(CreateAstBuilder(documentLocation));111 SpecFlowDocument specFlowDocument = parser.Parse(CreateTokenScanner(featureFileReader), CreateTokenMatcher());112113 CheckSemanticErrors(specFlowDocument);114115 return specFlowDocument;116 }117118 protected virtual ITokenScanner CreateTokenScanner(TextReader featureFileReader)119 {120 return new TokenScanner(featureFileReader);121 }122123 protected virtual ITokenMatcher CreateTokenMatcher()124 {125 return new TokenMatcher(dialectProvider);126 }127128 protected virtual IAstBuilder<SpecFlowDocument> CreateAstBuilder(SpecFlowDocumentLocation documentLocation)129 {130 return new SpecFlowAstBuilder(documentLocation);131 }132133 protected virtual void CheckSemanticErrors(SpecFlowDocument specFlowDocument)134 {135 if (specFlowDocument?.SpecFlowFeature == null)136 return;137138 var errors = semanticValidators139 .SelectMany(x => x.Validate(specFlowDocument.SpecFlowFeature))140 .ToList();141142 // collect143 if (errors.Count == 1)144 throw errors[0]; ...

Full Screen

Full Screen

AstEventConverter.cs

Source:AstEventConverter.cs Github

copy

Full Screen

...5using Gherkin.Events.Args.Ast;6using Comment = Gherkin.Events.Args.Ast.Comment;7using Examples = Gherkin.Events.Args.Ast.Examples;8using Feature = Gherkin.Events.Args.Ast.Feature;9using Location = Gherkin.Events.Args.Ast.Location;10using Rule = Gherkin.Events.Args.Ast.Rule;11using Step = Gherkin.Events.Args.Ast.Step;12using StepsContainer = Gherkin.Events.Args.Ast.StepsContainer;13namespace Gherkin.Stream.Converter14{15 public class AstEventConverter16 {17 public GherkinDocumentEventArgs ConvertGherkinDocumentToEventArgs(GherkinDocument gherkinDocument, string sourceEventUri)18 {19 return new GherkinDocumentEventArgs()20 {21 Uri = sourceEventUri,22 Feature = ConvertFeature(gherkinDocument),23 Comments = ConvertComments(gherkinDocument)24 };25 }26 private IReadOnlyCollection<Comment> ConvertComments(GherkinDocument gherkinDocument)27 {28 return gherkinDocument.Comments.Select(c =>29 new Comment()30 {31 Text = c.Text,32 Location = ConvertLocation(c.Location)33 }).ToReadOnlyCollection();34 }35 private Feature ConvertFeature(GherkinDocument gherkinDocument)36 {37 var feature = gherkinDocument.Feature;38 if (feature == null)39 {40 return null;41 }42 return new Feature()43 {44 Name = feature.Name == string.Empty ? null : feature.Name,45 Keyword = feature.Keyword,46 Language = feature.Language,47 Location = ConvertLocation(feature.Location),48 Children = feature.Children.Select(ConvertToChildren).ToReadOnlyCollection()49 };50 }51 private static Location ConvertLocation(Ast.Location location)52 {53 return new Location(location.Column, location.Line);54 }55 private Children ConvertToChildren(IHasLocation hasLocation)56 {57 switch (hasLocation)58 {59 case Background background:60 return new Children()61 {62 Background = new StepsContainer()63 {64 Location = ConvertLocation(background.Location),65 Name = background.Name == string.Empty ? null : background.Name,66 Keyword = background.Keyword,67 Steps = background.Steps.Select(s => ConvertStep(s)).ToList()68 }69 };70 case Scenario scenario:71 return new Children()72 {73 Scenario = new StepsContainer()74 {75 Keyword = scenario.Keyword,76 Location = ConvertLocation(scenario.Location),77 Name = scenario.Name == string.Empty ? null : scenario.Name,78 Steps = scenario.Steps.Select(s => ConvertStep(s)).ToList(),79 Examples = scenario.Examples.Select(ConvertExamples).ToReadOnlyCollection(),80 }81 };82 case Ast.Rule rule:83 {84 return new Children()85 {86 Rule = new Rule()87 {88 Name = rule.Name == string.Empty ? null : rule.Name,89 Keyword = rule.Keyword,90 Children = rule.Children.Select(ConvertToChildren).ToReadOnlyCollection(),91 Location = ConvertLocation(rule.Location)92 }93 };94 }95 default:96 throw new NotImplementedException();97 }98 }99 private Examples ConvertExamples(Ast.Examples examples)100 {101 return new Examples()102 {103 Name = examples.Name == string.Empty ? null : examples.Name,104 Keyword = examples.Keyword,105 Description = examples.Description,106 Location = ConvertLocation(examples.Location),107 TableHeader = ConvertTableHeader(examples),108 TableBody = ConvertToTableBody(examples)109 };110 }111 private IReadOnlyCollection<TableBody> ConvertToTableBody(Ast.Examples examples)112 {113 if (examples.TableBody == null)114 return new List<TableBody>();115 return examples.TableBody.Select(b =>116 new TableBody()117 {118 Location = ConvertLocation(b.Location),119 Cells = b.Cells.Select(ConvertCell).ToReadOnlyCollection()120 }).ToReadOnlyCollection();121 }122 private TableHeader ConvertTableHeader(Ast.Examples examples)123 {124 if (examples.TableHeader == null)125 return null;126 return new TableHeader()127 {128 Location = ConvertLocation(examples.TableHeader.Location),129 Cells = examples.TableHeader.Cells.Select(ConvertCell).ToReadOnlyCollection()130 };131 }132 private Cell ConvertCell(TableCell c)133 {134 return new Cell()135 {136 Value = c.Value,137 Location = ConvertLocation(c.Location)138 };139 }140 private Step ConvertStep(Ast.Step step)141 {142 return new Step()143 {144 Keyword = step.Keyword,145 Text = step.Text,146 Location = ConvertLocation(step.Location)147 };148 }149 }150}...

Full Screen

Full Screen

DeveroomGherkinAstBuilder.cs

Source:DeveroomGherkinAstBuilder.cs Github

copy

Full Screen

...23 base.Build(token);24 if (token.MatchedType == TokenType.Language)25 {26 // the language token should be handled as comment as well27 var commentToken = new Token(token.Line, new Location(token.Location.Line, 1))28 {29 MatchedType = TokenType.Comment,30 MatchedText = token.Line.GetLineText(),31 };32 base.Build(commentToken);33 }34 }35 private static StepKeyword GetStepKeyword(GherkinDialect dialect, string stepKeyword)36 {37 if (dialect.AndStepKeywords.Contains(stepKeyword)) // we need to check "And" first, as the '*' is also part of the Given, When and Then keywords38 return StepKeyword.And;39 if (dialect.GivenStepKeywords.Contains(stepKeyword))40 return StepKeyword.Given;41 if (dialect.WhenStepKeywords.Contains(stepKeyword))42 return StepKeyword.When;43 if (dialect.ThenStepKeywords.Contains(stepKeyword))44 return StepKeyword.Then;45 if (dialect.ButStepKeywords.Contains(stepKeyword))46 return StepKeyword.But;47 return StepKeyword.And;48 }49 protected override Step CreateStep(Location location, string keyword, string text, StepArgument argument, AstNode node)50 {51 var token = node.GetToken(TokenType.StepLine);52 var stepKeyword = GetStepKeyword(token.MatchedGherkinDialect, keyword);53 _scenarioBlock = stepKeyword.ToScenarioBlock() ?? _scenarioBlock;54 return new DeveroomGherkinStep(location, keyword, text, argument, stepKeyword, _scenarioBlock);55 }56 private void ResetBlock()57 {58 _scenarioBlock = ScenarioBlock.Given;59 }60 protected override GherkinDocument CreateGherkinDocument(Feature feature, Comment[] gherkinDocumentComments, AstNode node)61 {62 return new DeveroomGherkinDocument(feature, gherkinDocumentComments, _sourceFilePath, _documentDialectProvider(), _statesForLines);63 }64 protected override Scenario CreateScenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples, AstNode node)65 {66 ResetBlock();67 if (examples == null || examples.Length == 0)68 {69 return new SingleScenario(tags, location, keyword, name, description, steps, examples);70 }71 else72 {73 return new ScenarioOutline(tags, location, keyword, name, description, steps, examples);74 }75 }76 protected override Background CreateBackground(Location location, string keyword, string name, string description, Step[] steps, AstNode node)77 {78 ResetBlock();79 return base.CreateBackground(location, keyword, name, description, steps, node);80 }81 protected override void HandleAstError(string message, Location location)82 {83 _errors.Add(new SemanticParserException(message, location));84 }85 public void RecordStateForLine(int line, int state)86 {87 if (line > 0)88 line--; // convert to 0 based89 if (_statesForLines.Count > line)90 return;91 if (_statesForLines.Count < line)92 {93 var lastState = _statesForLines.Any() ? _statesForLines.Last() : -1;94 while (_statesForLines.Count < line)95 _statesForLines.Add(lastState);...

Full Screen

Full Screen

GherkinScenarioDefinitionTests.cs

Source:GherkinScenarioDefinitionTests.cs Github

copy

Full Screen

...20 var backgroundSteps = new Gherkin.Ast.Step[] { new Gherkin.Ast.Step(null, null, "background", null) };21 var background = new Gherkin.Ast.Background(null, null, null, null, backgroundSteps);22 var modified = scenario.ApplyBackground(background);23 24 Assert.Equal(scenario.Location, modified.Location);25 Assert.Equal(scenario.Keyword, modified.Keyword);26 Assert.Equal(scenario.Name, modified.Name);27 Assert.Equal(scenario.Description, modified.Description);28 29 Assert.Equal(2, modified.Steps.Count());30 Assert.Equal("background", modified.Steps.ElementAt(0).Text);31 Assert.Equal("step", modified.Steps.ElementAt(1).Text);32 } 33 private static Gherkin.Ast.Scenario CreateTestScenario()34 {35 var tags = new Gherkin.Ast.Tag[] { new Gherkin.Ast.Tag(null, "test") };36 var location = new Gherkin.Ast.Location(1, 1);37 var steps = new Gherkin.Ast.Step[] { new Gherkin.Ast.Step(null, null, "step", null) };38 return new Gherkin.Ast.Scenario(tags, location, "keyword", "name", "description", steps); 39 }40 }41}...

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Gherkin.Ast;7{8 {9 static void Main(string[] args)10 {11 Location location = new Location(1, 2);12 Console.WriteLine(location.Line);13 Console.WriteLine(location.Column);14 Console.ReadLine();15 }16 }17}18using System;19using System.Collections.Generic;20using System.Linq;21using System.Text;22using System.Threading.Tasks;23using Gherkin.Ast;24{25 {26 static void Main(string[] args)27 {28 Location location = new Location(1, 2);29 Console.WriteLine(location.ToString());30 Console.ReadLine();31 }32 }33}34using System;35using System.Collections.Generic;36using System.Linq;37using System.Text;38using System.Threading.Tasks;39using Gherkin.Ast;40{41 {42 static void Main(string[] args)43 {44 Location location = new Location(1, 2);45 Console.WriteLine(location.GetHashCode());46 Console.ReadLine();47 }48 }49}50using System;51using System.Collections.Generic;52using System.Linq;53using System.Text;54using System.Threading.Tasks;55using Gherkin.Ast;56{57 {58 static void Main(string[] args)59 {60 Location location = new Location(1, 2);61 Console.WriteLine(location.Equals(location));62 Console.ReadLine();63 }64 }65}66using System;67using System.Collections.Generic;68using System.Linq;69using System.Text;70using System.Threading.Tasks;71using Gherkin.Ast;72{73 {74 static void Main(string[] args)75 {76 Location location = new Location(1, 2);77 Console.WriteLine(location.Equals(null));78 Console.ReadLine();79 }

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using TechTalk.SpecFlow;7using TechTalk.SpecFlow.Parser.SyntaxElements;8{9 {10 [Given(@"I have entered (.*) into the calculator")]11 public void GivenIHaveEnteredIntoTheCalculator(int p0)12 {13 ScenarioContext.Current.Pending();14 }15 [Given(@"I have entered (.*) into the calculator")]16 public void GivenIHaveEnteredIntoTheCalculator(int p0, Table table)17 {18 ScenarioContext.Current.Pending();19 }20 [Given(@"I have entered (.*) into the calculator")]21 public void GivenIHaveEnteredIntoTheCalculator(int p0, string multilineText)22 {23 ScenarioContext.Current.Pending();24 }25 [Given(@"I have entered (.*) into the calculator")]26 public void GivenIHaveEnteredIntoTheCalculator(int p0, DocString docString)27 {28 ScenarioContext.Current.Pending();29 }30 [Given(@"I have entered (.*) into the calculator")]31 public void GivenIHaveEnteredIntoTheCalculator(int p0, string multilineText, Table table)32 {33 ScenarioContext.Current.Pending();34 }35 [Given(@"I have entered (.*) into the calculator")]36 public void GivenIHaveEnteredIntoTheCalculator(int p0, Table table, string multilineText)37 {38 ScenarioContext.Current.Pending();39 }40 [Given(@"I have entered (.*) into the calculator")]41 public void GivenIHaveEnteredIntoTheCalculator(int p0, DocString docString, Table table)42 {43 ScenarioContext.Current.Pending();44 }45 [Given(@"I have entered (.*) into the calculator")]46 public void GivenIHaveEnteredIntoTheCalculator(int p0, Table table, DocString docString)47 {48 ScenarioContext.Current.Pending();49 }50 }51}52using System;53using System.Collections.Generic;54using System.Linq;55using System.Text;56using System.Threading.Tasks;57using TechTalk.SpecFlow;58using TechTalk.SpecFlow.Parser.SyntaxElements;59{60 {61 [Given(@"I have entered (.*) into the calculator")]

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1using System;2using Gherkin.Ast;3{4 {5 static void Main(string[] args)6 {7 Location loc = new Location(1, 1, 1);8 Console.WriteLine(loc.ToString());9 }10 }11}

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1var location = new Location(1, 2);2Console.WriteLine(location.Line);3Console.WriteLine(location.Column);4var step = new Step(new Gherkin.Ast.Location(1, 2), "Given", "I am in step", new List<DataTableRow>(), new List<Tag>());5Console.WriteLine(step.Location.Line);6Console.WriteLine(step.Location.Column);7var scenario = new Scenario(new Gherkin.Ast.Location(1, 2), "Scenario", "I am in scenario", new List<Tag>(), new List<Step>(), new List<Comment>());8Console.WriteLine(scenario.Location.Line);9Console.WriteLine(scenario.Location.Column);10var background = new Background(new Gherkin.Ast.Location(1, 2), "Background", "I am in background", new List<Tag>(), new List<Step>(), new List<Comment>());11Console.WriteLine(background.Location.Line);12Console.WriteLine(background.Location.Column);13var rule = new Rule(new Gherkin.Ast.Location(1, 2), "Rule", "I am in rule", new List<Tag>(), new List<ScenarioDefinition>(), new List<Comment>());14Console.WriteLine(rule.Location.Line);15Console.WriteLine(rule.Location.Column);16var feature = new Feature(new Gherkin.Ast.Location(1, 2), "Feature", "I am in feature", "Description", new List<Tag>(), new List<ScenarioDefinition>(), new List<Comment>(), Language.Afrikaans);17Console.WriteLine(feature.Location.Line);18Console.WriteLine(feature.Location.Column);19var comment = new Comment(new Gherkin.Ast.Location(1, 2), "#I am in comment");20Console.WriteLine(comment.Location.Line);21Console.WriteLine(comment.Location.Column);22var dataTableRow = new DataTableRow(new Gherkin.A

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1using Gherkin.Ast;2using System;3{4 {5 static void Main(string[] args)6 {7 Location loc = new Location(1, 2);8 Console.WriteLine("Column: " + loc.Column);9 Console.WriteLine("Line: " + loc.Line);10 }11 }12}

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1using System;2using Gherkin.Ast;3{4 {5 static void Main(string[] args)6 {7 Console.WriteLine("Hello World!");8 Location loc = new Location(1, 2);9 int line = loc.Line;10 Console.WriteLine("Line number is: " + line);11 }12 }13}

Full Screen

Full Screen

Location

Using AI Code Generation

copy

Full Screen

1using System;2using Gherkin.Ast;3{4{5static void Main(string[] args)6{7Location location = new Location(1, 2);8int lineNumber = location.Line;9Console.WriteLine("Line number is: " + lineNumber);10}11}12}

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 method in Location

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful