Exemple #1
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            timings.Start(specification);

            IExecutionContext execution = null;

            using (timings.Subject("Context", "Creation"))
            {
                execution = _system.CreateContext();
            }

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

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

            var executor = new SynchronousExecutor(context);

            plan.AcceptVisitor(executor);



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

            return(context.FinalizeResults(1));
        }
        protected void executeSpec(Specification spec)
        {
            _context = new SpecContext(spec, null, new NulloResultObserver(), new StopConditions(), new TestExecutionContext(Services));

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

            var executor = new SynchronousExecutor(_context);

            plan.AcceptVisitor(executor);
        }
        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(header =>
            {
                var spec = header;
                spec.ReadBody();
                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 executor = new SynchronousExecutor(context);

                        plan.AcceptVisitor(executor);

                        observer.SpecExecutionFinished(header, 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 = ".".ToFullPath().ParentDirectory().ParentDirectory().ParentDirectory().ParentDirectory().AppendPath("client");

            new FileSystem().WriteStringToFile(clientPath.AppendPath("all-spec-data.js"), "module.exports = " + json);
            Debug.WriteLine("Wrote file to all-spec-data.js");
        }
        public SynchronousExecutorTest()
        {
            this.executionContext = new Mock<IExecutionContext>();

            this.testee = new SynchronousExecutor<IExtension>();
        }