private void GenerateScenarioOutlineTestVariant(CodeTypeDeclaration testType, ScenarioOutline scenarioOutline, string testMethodName, List <KeyValuePair <string, string> > paramToIdentifier, string exampleSetTitle, Row row, Tags exampleSetTags, string variantName, ExampleSet exampleSet) { CodeMemberMethod testMethod = GetTestMethodDeclaration(testType, scenarioOutline, exampleSetTags); testMethod.Name = string.IsNullOrEmpty(exampleSetTitle) ? string.Format("{0}_{1}", testMethod.Name, variantName) : string.Format("{0}_{1}_{2}", testMethod.Name, exampleSetTitle, variantName); //call test implementation with the params List <CodeExpression> argumentExpressions = new List <CodeExpression>(); foreach (var paramCell in row.Cells) { argumentExpressions.Add(new CodePrimitiveExpression(paramCell.Value)); } argumentExpressions.Add(GetStringArrayExpression(exampleSetTags)); testMethod.Statements.Add( new CodeMethodInvokeExpression( new CodeThisReferenceExpression(), testMethodName, argumentExpressions.ToArray())); List <KeyValuePair <string, string> > arguments = new List <KeyValuePair <string, string> >(); for (int rowIndex = 0; rowIndex < exampleSet.Table.Body.Length; rowIndex++) { arguments.Add(new KeyValuePair <string, string>(exampleSet.Table.Header.Cells[rowIndex].Value, row.Cells[rowIndex].Value)); } testGeneratorProvider.SetTestVariant(testMethod, scenarioOutline.Title, exampleSetTitle, arguments); }
private void GenerateScenarioOutlineTestVariant(CodeTypeDeclaration testType, ScenarioOutline scenarioOutline, string testMethodName, IEnumerable <KeyValuePair <string, string> > paramToIdentifier, string exampleSetTitle, string exampleSetIdentifier, Row row, Tags exampleSetTags, string variantName) { var variantNameIdentifier = variantName.ToIdentifier().TrimStart('_'); CodeMemberMethod testMethod = GetTestMethodDeclaration(testType, 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(), testMethodName, argumentExpressions.ToArray())); var arguments = paramToIdentifier.Select((p2i, paramIndex) => new KeyValuePair <string, string>(p2i.Key, row.Cells[paramIndex].Value)).ToList(); testGeneratorProvider.SetTestVariant(testMethod, scenarioOutline.Title, exampleSetTitle, variantName, arguments); }