private void GenerateScenarioOutlineTestVariant(TestClassGenerationContext generationContext, ScenarioOutline scenarioOutline, CodeMemberMethod scenatioOutlineTestMethod, IEnumerable <KeyValuePair <string, string> > paramToIdentifier, string exampleSetTitle, string exampleSetIdentifier, GherkinTableRow row, Tags exampleSetTags, string variantName) { var variantNameIdentifier = variantName.ToIdentifier().TrimStart('_'); CodeMemberMethod testMethod = CreateTestMethod(generationContext, scenarioOutline, exampleSetTags); testMethod.Name = string.IsNullOrEmpty(exampleSetIdentifier) ? string.Format("{0}_{1}", testMethod.Name, variantNameIdentifier) : string.Format("{0}_{1}_{2}", testMethod.Name, exampleSetIdentifier, variantNameIdentifier); //call test implementation with the params List <CodeExpression> argumentExpressions = row.Cells.Select(paramCell => new CodePrimitiveExpression(paramCell.Value)).Cast <CodeExpression>().ToList(); argumentExpressions.Add(GetStringArrayExpression(exampleSetTags)); testMethod.Statements.Add( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), scenatioOutlineTestMethod.Name, argumentExpressions.ToArray())); var arguments = paramToIdentifier.Select((p2i, paramIndex) => new KeyValuePair <string, string>(p2i.Key, row.Cells[paramIndex].Value)).ToList(); testGeneratorProvider.SetTestMethodAsRow(generationContext, testMethod, scenarioOutline.Title, exampleSetTitle, variantName, arguments); }
private GherkinTableRow Clone(GherkinTableRow row) { return(new GherkinTableRow(row.Cells.Select(c => new GherkinTableCell() { Value = c.Value }).ToArray())); }
private void CalculateWidth(int[] widths, GherkinTableRow row) { int i = 0; foreach (var cell in row.Cells) { widths[i] = Math.Max(widths[i], cell.Value.Length); i++; } }
public void ProcessTableRow(string[] cells, FilePosition rowPosition) { var row = new GherkinTableRow(cells.Select(c => new GherkinTableCell(c)).ToArray()); row.FilePosition = rowPosition; if (tableRows.Count > 0 && tableRows[0].Cells.Length != row.Cells.Length) { throw new GherkinSemanticErrorException( "Number of cells in the row does not match the number of cells in the header.", row.FilePosition); } tableRows.Add(row); }
protected virtual void AppendTableRow(StringBuilder result, GherkinTableRow row, string tableIndent, int[] widths) { result.Append(tableIndent); int i = 0; foreach (var cell in row.Cells) { result.Append("| "); result.Append(cell.Value); result.Append(new string(' ', widths[i] - cell.Value.Length)); result.Append(" "); i++; } result.Append("|"); AppendLine(result); }