/// <summary> /// Enumerates over this and each of its ancestors. Reverse the collection to go through the story in correct order /// </summary> /// <returns>IEnumerable<IStepContainer>.</returns> IEnumerable <IStepContainer> IStepContainer.SelfAndAncestors() { for (IStepContainer f = this; f != null; f = f.Parent) { yield return(f); } }
private string Code(IStepContainer b) { CodeWriter writer = new CodeWriter(); this.Settings.GetCodeGenerator().Generate(b.SelfAndAncestors().Reverse().ToList(), writer); return(writer.ToString()); }
public void Generate(IEnumerable <IStepContainer> fragments, CodeWriter writer) { IStepContainer first = fragments.First(); string s = Regex.Replace(" " + first.Step.Text, " \\w|_", match => match.Value.Trim().ToUpperInvariant()); writer.WriteLine("[" + this.testFrameworkData.TestMethodAttribute + "]"); writer.WriteLine("public void " + s + "()"); using (writer.CodeBlock()) { this.child.Generate(fragments, writer); } }
/// <summary> /// Initializes a new instance of the <see cref="FragmentBase" /> class. /// </summary> /// <param name="step">The step.</param> /// <param name="parent">The parent.</param> public FragmentBase(Step step, IStepContainer parent) { this.step = step; this.parent = parent; }