Пример #1
0
        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));
        }
Пример #2
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));
        }
        public void run_with_non_zero_threshold_that_is_not_exceeded()
        {
            using (var timings = new Timings())
            {
                timings.Start(new Specification());

                var record = timings.Subject("something", "else", 100);
                timings.End(record);

                timings.Finish();

                record.PerfViolation.ShouldBeFalse();
            }
        }
        public void run_with_zero_threshold()
        {
            using (var timings = new Timings())
            {
                timings.Start(new Specification());

                var record = timings.Subject("something", "else", 0);

                Thread.Sleep(100);

                timings.End(record);

                timings.Finish();

                record.PerfViolation.ShouldBeFalse();
            }
        }
Пример #5
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));
        }