public void record_data()
        {
            var spec = new Specification
            {
                name = "Some Name"
            };

            var timings = new Timings();
            timings.Start(spec);
            using (timings.Subject("Fixture.Setup", "Math"))
            {
                using (timings.Subject("Grammar", "Adding"))
                {
                    using (timings.Subject("Fixture.Teardown", "Math"))
                    {
                        Thread.Sleep(100);
                    }
                }
            }

            var records = timings.Finish();

            records.Select(x => x.Subject).ShouldHaveTheSameElementsAs("Some Name", "Math", "Adding", "Math");

            records.Each(x => x.Duration.ShouldBeGreaterThan(0));
        }
        private IExecutionContext createExecutionContext(ISystem system, Timings timings)
        {
            var record = timings.Subject("Context", "Creation", 0);

            try
            {
                return(system.CreateContext());
            }
            catch (Exception e)
            {
                Request.Cancel();

                throw new StorytellerExecutionException(e);
            }
            finally
            {
                timings.End(record);
            }
        }
Exemple #3
0
        private void execute()
        {
            try
            {
                using (_timings.Subject("Context", "Creation"))
                {
                    _execution = _system.CreateContext();
                }
            }
            catch (Exception e)
            {
                _catastrophicException = e;
                _reset.Set();

                return;
            }

            if (_request.IsCancelled)
            {
                return;
            }

            _context = new SpecContext(_request.Specification, _timings, _request.Observer, _stopConditions, _execution);

            try
            {
                _execution.BeforeExecution(_context);
            }
            catch (Exception e)
            {
                _context.LogException(_request.Id, e, "BeforeExecution");
            }

            _context.Reporting.As <Reporting>().StartDebugListening();
            var executor = _mode.BuildExecutor(_request.Plan, _context);

            _request.Plan.AcceptVisitor(executor);

            _execution.AfterExecution(_context);

            _reset.Set();
        }
        private IExecutionContext createExecutionContext(ISystem system, Timings timings)
        {
            try
            {
                using (timings.Subject("Context", "Creation"))
                {
                    return system.CreateContext();
                }
            }
            catch (Exception e)
            {
                Request.Cancel();

                throw new StorytellerExecutionException(e);
            }
        }