private void WriteContextSetup(Scenario scenario) { _blockWriter.AppendLine(@"[TestFixtureSetUp]"); _blockWriter.AppendLine(@"protected void BeforeAll()"); _blockWriter.WrapWithBraces(() => scenario.Givens .Union(scenario.Whens) .ToList() .ForEach(s => _blockWriter.AppendLine(string.Format("{0}();", s)))); }
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)); }