Exemple #1
0
        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();
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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();
        }
Exemple #4
0
 public void BuildScenario(Scenario scenario, Context context)
 {
     _applicationHost.WriteFile(string.Format(@"{0}\{1}.cs", context.Namespace, scenario), Build(scenario, context));
 }
Exemple #5
0
 public void BuildContext(Context context)
 {
     _applicationHost.CreateDirectory(context.Namespace);
     _applicationHost.WriteFile(string.Format(@"{0}\{1}.cs", context.Namespace, context.MemberName), Build(context));
 }