public override string GetFileSkeleton(List<StepArgs> steps, StepDefSkeletonInfo info) { List<string> givens, whens, thens; GroupByBindingType(steps, out givens, out whens, out thens); string body = GetStructuredMethodsSkeleton(givens, whens, thens).Indent(CODEINDENT); StringBuilder result = new StringBuilder(); result.AppendFormat( @"using System; using System.Collections.Generic; using System.Linq; using System.Text; using TechTalk.SpecFlow; namespace {0} {{ {4}[{1}] {4}public class {2} {4}{{ {3}{4}{4} {4}}} }}", info.NamespaceName, GetAttributeName(typeof(BindingAttribute)), info.SuggestedStepDefName, body, CODEINDENT); result.AppendLine(); return result.ToString(); }
public override string GetFileSkeleton(List<StepArgs> steps, StepDefSkeletonInfo info) { string body = CombineMethods(GetCombinedMethodsSkeleton(steps)); StringBuilder result = new StringBuilder(); result.AppendFormat( @"Imports TechTalk.SpecFlow <{0}> _ Public Class {2} {3} {1}End Class", GetAttributeName(typeof(BindingAttribute)), body, info.SuggestedStepDefName, CODEINDENT); result.AppendLine(); return result.ToString(); }
public abstract string GetFileSkeleton(List<StepArgs> steps, StepDefSkeletonInfo info);
public void Produces_CSharp_Class_File_Skeleton() { var expected = new StringBuilder(); expected.Append( @"using System; using System.Collections.Generic; using System.Linq; using System.Text; using TechTalk.SpecFlow; namespace SpecFlow.Testing { [Binding] public class StepsForTest { #region Given [Given(@""I have a new step"")] public void GivenIHaveANewStep() { ScenarioContext.Current.Pending(); } #endregion #region Then [Then(@""I get a suggestion"")] public void ThenIGetASuggestion() { ScenarioContext.Current.Pending(); } #endregion } } "); string expectedString = expected.ToString(); var steps = new List<StepArgs> { new StepArgs(BindingType.Given, StepDefinitionKeyword.Given, "I have a new step", null, null, null), new StepArgs(BindingType.Then, StepDefinitionKeyword.Then, "I get a suggestion", null, null, null), }; var skelInfo = new StepDefSkeletonInfo("StepsForTest", "SpecFlow.Testing"); string output = skeletonProviderCS.GetFileSkeleton(steps, skelInfo); Assert.AreEqual(expectedString, output); }
public void Produces_VBasic_Class_File_Skeleton() { var expected = new StringBuilder(); expected.Append( @"Imports TechTalk.SpecFlow <Binding> _ Public Class StepsForTest <Given(""I have a new step"")> _ Public Sub GivenIHaveANewStep() ScenarioContext.Current.Pending() End Sub <TechTalk.SpecFlow.When(""I do not find a step binding"")> _ Public Sub WhenIDoNotFindAStepBinding() ScenarioContext.Current.Pending() End Sub <TechTalk.SpecFlow.Then(""I get a suggestion"")> _ Public Sub ThenIGetASuggestion() ScenarioContext.Current.Pending() End Sub End Class "); string expectedString = expected.ToString(); var steps = new List<StepArgs> { new StepArgs(BindingType.Given, StepDefinitionKeyword.Given, "I have a new step", null, null, null), new StepArgs(BindingType.When, StepDefinitionKeyword.When, "I do not find a step binding", null, null, null), new StepArgs(BindingType.Then, StepDefinitionKeyword.Then, "I get a suggestion", null, null, null) }; var skelInfo = new StepDefSkeletonInfo("StepsForTest", "namespace"); string output = skeletonProviderVB.GetFileSkeleton(steps, skelInfo); Assert.AreEqual(expectedString, output); }