private string Build(Context context) { _blockWriter.AppendLine(@"using System;"); _blockWriter.AppendLine(@"using NUnit.Framework;"); _blockWriter.AppendLine(); _blockWriter.AppendLine(string.Format(@"namespace {0}", context.Namespace)); _blockWriter.WrapWithBraces(() => WriteContext(context)); return _blockWriter.Flush(); }
private void WriteContext(Context context) { _blockWriter.AppendLine(string.Format(@"public class {0}", context)); _blockWriter.WrapWithBraces(() => context.Scenarios .SelectMany(s => s.Givens) .Union(context.Scenarios.SelectMany(s => s.Whens)) .Distinct() .ToList() .ForEach(WriteGivenWhen)); }
private string Build(Scenario scenario, Context context) { _blockWriter.AppendLine(@"using System;"); _blockWriter.AppendLine(@"using NUnit.Framework;"); _blockWriter.AppendLine(); _blockWriter.AppendLine(string.Format(@"namespace {0}", context.Namespace)); _blockWriter.WrapWithBraces(() => { _blockWriter.AppendLine(@"[TestFixture]"); _blockWriter.AppendLine(string.Format(@"public class {0} : {1}", scenario, context)); _blockWriter.WrapWithBraces(() => { WriteContextSetup(scenario); WriteContextTearDown(); scenario.Thens.ToList().ForEach(WriteThen); }); }); return _blockWriter.Flush(); }
public void BuildScenario(Scenario scenario, Context context) { _applicationHost.WriteFile(string.Format(@"{0}\{1}.cs", context.Namespace, scenario), Build(scenario, context)); }
public void BuildContext(Context context) { _applicationHost.CreateDirectory(context.Namespace); _applicationHost.WriteFile(string.Format(@"{0}\{1}.cs", context.Namespace, context.MemberName), Build(context)); }