//[Fact]
        public void record_and_save_file()
        {
            var data = new ClientData();

            var library = TestingContext.Library;


            var hierarchy = TestingContext.Hierarchy;

            hierarchy.GetAllSpecs().Each(x => x.path.ShouldNotBeNull());

            hierarchy.GetAllSpecs().Each(spec =>
            {
                data.specs.Add(spec.id, spec);

                using (var execution = theSystem.CreateContext())
                {
                    var observer = new RecordingObserver(data.results);
                    using (var context = new SpecContext(spec, null, observer, new StopConditions(), execution)
                           )
                    {
                        context.Reporting.As <Reporting>().StartDebugListening();
                        var plan = spec.CreatePlan(library);

                        var gatherer = new LineStepGatherer(context);
                        plan.AcceptVisitor(gatherer);

                        foreach (var line in gatherer.Lines)
                        {
                            line.Execute(context);
                        }

                        observer.SpecExecutionFinished(spec, context.FinalizeResults(1));
                    }
                }
            });

            data.specs.Values.Each(x => x.path.ShouldNotBeNull());

            data.hierarchy = hierarchy;
            data.fixtures  = library.Models.Where(x => x.implementation.Contains("StoryTeller.Samples")).ToArray();

            var json = JsonSerialization.ToIndentedJson(data);

            var clientPath = TestingContext.FindClientFolder();

            new FileSystem().WriteStringToFile(clientPath.AppendPath("all-spec-data.js"), "module.exports = " + json);
            Debug.WriteLine("Wrote file to all-spec-data.js");
        }
示例#2
0
        protected void executeSpec(Specification spec)
        {
            _context = new SpecContext(spec, null, new NulloResultObserver(), new StopConditions(), new TestExecutionContext(Services));

            var plan = spec.CreatePlan(TestingContext.Library);

            var gatherer = new LineStepGatherer(_context);

            plan.AcceptVisitor(gatherer);

            foreach (var line in gatherer.Lines)
            {
                line.Execute(_context);
            }
        }
示例#3
0
        public void can_gather_up_the_lines()
        {
            var gatherer = new LineStepGatherer(Execution.Context);
            var plan     = Specification.CreatePlan(TestingContext.Library);

            plan.AcceptVisitor(gatherer);

            gatherer.Lines.Count.ShouldBe(7);

            gatherer.Lines[0].ShouldBeOfType <SilentAction>();

            gatherer.Lines[1].ShouldBeOfType <LineStep>();
            gatherer.Lines[2].ShouldBeOfType <LineStep>();
            gatherer.Lines[3].ShouldBeOfType <LineStep>();
            gatherer.Lines[4].ShouldBeOfType <LineStep>();
            gatherer.Lines[5].ShouldBeOfType <LineStep>();

            gatherer.Lines.Last().ShouldBeOfType <SilentAction>();
        }
示例#4
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            timings.Start(specification);

            IExecutionContext execution = null;

            var record = timings.Subject("Context", "Creation", 0);

            try
            {
                execution = _system.CreateContext();
            }
            finally
            {
                timings.End(record);
            }

            var context = new SpecContext(specification, timings, new NulloResultObserver(), StopConditions,
                                          execution);

            context.Reporting.As <Reporting>().StartDebugListening();

            var gatherer = new LineStepGatherer(context);

            plan.AcceptVisitor(gatherer);

            foreach (var line in gatherer.Lines)
            {
                line.Execute(context);
            }

            execution.Dispose();
            context.Dispose();

            return(context.FinalizeResults(1));
        }