public SyntaxScenarioWithExamples(IGherkinScenario scenario) { foreach (var value in scenario.Examples) { foreach (var el in value.TestCases.Values) { this.testCases.Add(new TestCaseSignature(el, MethodArgType.Argument)); } } var sig = new TestCaseSignature(scenario.Examples[0].TestCases.Parameters, MethodArgType.Parameter); this.Signature = this.testCases.Any() ? sig.Join(this.testCases[0]) : sig; }
protected override IEnumerable <string> SyntaxCore() { if (!this.initialized) { throw new InvalidOperationException("Sub-classes need to call Initialize in their constructor"); } var builder = new SpockCollectionString(); builder.AppendLine(); var testCaseName = $"{this.id}TestCases()"; builder.AppendLine("private {0} {1}", this.testCaseType, testCaseName); builder.AppendLine("{"); foreach (var element in this.methodTestCases) { if (this.moreThanOneArg) { builder.AppendLine( " yield return new {0}{1:v};", this.typeSyntax, element); } else { foreach (var argument in element.Arguments) { builder.AppendLine( " yield return {0:v};", argument); } } } builder.AppendLine("}"); if (this.GenerateType && this.moreThanOneArg) { var sig = new TestCaseSignature(this.step.TestCase.Parameters, MethodArgType.Parameter); var signature = sig.Join(this.methodTestCases[0]); builder.AppendLine(); builder.AppendLine("private partial class {0}", this.typeSyntax); builder.AppendLine("{"); builder.AppendLine(" public {0}{1}", this.typeSyntax, signature); builder.AppendLine(" {"); signature.Arguments.ForAll(x => builder.AppendLine(" {0:p} = {0:v};", x)); builder.AppendLine(" }"); signature.Arguments.ForAll(x => { builder.AppendLine(); builder.AppendLine(" public {0:t} {0:p} {{ get; private set; }}", x); }); builder.AppendLine("}"); } builder.AppendLine(); builder.AppendLine(this.Signature); return(builder); }