Inheritance: FubuMVC.Core.Diagnostics.Instrumentation.ChainExecutionLog
        public void start_and_step_a_subject()
        {
            var subject1 = MockRepository.GenerateMock<ISubject>();
            var subject2 = MockRepository.GenerateMock<ISubject>();

            var log = new StubbedChainExecutionLog();
            log.RequestTime = 111;
            log.StartSubject(subject1);

            log.RequestTime = 222;
            log.StartSubject(subject2);

            log.RequestTime = 333;
            log.FinishSubject();

            log.RequestTime = 444;
            log.FinishSubject();

            log.Activity.Nested[0].Subject.ShouldBe(subject1);
            log.Activity.Nested[0].Start.ShouldBe(111);
            log.Activity.Nested[0].End.ShouldBe(444);

            log.Activity.Nested[0].Nested[0].Subject.ShouldBe(subject2);
            log.Activity.Nested[0].Nested[0].Start.ShouldBe(222);
            log.Activity.Nested[0].Nested[0].End.ShouldBe(333);
        }
        public void log_exception_once()
        {
            var subject1 = MockRepository.GenerateMock <ISubject>();
            var subject2 = MockRepository.GenerateMock <ISubject>();

            var log = new StubbedChainExecutionLog();

            log.StartSubject(subject1);
            log.StartSubject(subject2);

            var ex = new DivideByZeroException();

            log.LogException(ex);

            log.FinishSubject();
            log.LogException(ex);

            log.FinishSubject();
            log.LogException(ex);



            log.Steps.Select(x => x.Log).OfType <ExceptionReport>()
            .Single().ExceptionText.ShouldBe(ex.ToString());
        }
        public void start_and_step_a_subject()
        {
            var subject1 = MockRepository.GenerateMock <ISubject>();
            var subject2 = MockRepository.GenerateMock <ISubject>();

            var log = new StubbedChainExecutionLog();

            log.RequestTime = 111;
            log.StartSubject(subject1);

            log.RequestTime = 222;
            log.StartSubject(subject2);

            log.RequestTime = 333;
            log.FinishSubject();

            log.RequestTime = 444;
            log.FinishSubject();

            log.Activity.Nested[0].Subject.ShouldBe(subject1);
            log.Activity.Nested[0].Start.ShouldBe(111);
            log.Activity.Nested[0].End.ShouldBe(444);

            log.Activity.Nested[0].Nested[0].Subject.ShouldBe(subject2);
            log.Activity.Nested[0].Nested[0].Start.ShouldBe(222);
            log.Activity.Nested[0].Nested[0].End.ShouldBe(333);
        }
        public void deep_activity_logging()
        {
            var subject1 = MockRepository.GenerateMock<ISubject>();
            var subject2 = MockRepository.GenerateMock<ISubject>();

            var x1 = new Object();
            var x2 = new Object();
            var x3 = new Object();
            var x4 = new Object();

            var log = new StubbedChainExecutionLog();
            log.RequestTime = 1;
            log.Log(x1);

            log.StartSubject(subject1);
            log.RequestTime = 5;
            log.Log(x2);

            log.RequestTime = 10;
            log.StartSubject(subject2);
            log.Log(x3);

            log.RequestTime = 15;
            log.FinishSubject();
            log.Log(x4);

            var steps = log.Steps.OrderBy(x => x.RequestTime).ToArray();

            steps[0].Activity.Subject.ShouldBe(log);
            steps[1].Activity.Subject.ShouldBe(subject1);

            steps[2].Log.ShouldBe(x3);
            steps[2].Activity.Subject.ShouldBe(subject2);
            steps[3].Activity.Subject.ShouldBe(subject1);
        }
        public void has_exception()
        {
            var log = new StubbedChainExecutionLog();
            log.HadException.ShouldBeFalse();

            log.LogException(new NotImplementedException());

            log.HadException.ShouldBeTrue();
        }
        public void logging_sets_the_request_time_and_activity_at_parent()
        {
            var log = new StubbedChainExecutionLog();
            log.RequestTime = 111;

            log.Log(new object());

            log.Steps.Single().RequestTime.ShouldBe(111);
            log.Steps.Single().Activity.ShouldBe(log.Activity);
        }
        public void has_exception()
        {
            var log = new StubbedChainExecutionLog();

            log.HadException.ShouldBeFalse();

            log.LogException(new NotImplementedException());

            log.HadException.ShouldBeTrue();
        }
        public void logging_sets_the_request_time_and_activity_at_parent()
        {
            var log = new StubbedChainExecutionLog();

            log.RequestTime = 111;

            log.Log(new object());

            log.Steps.Single().RequestTime.ShouldBe(111);
            log.Steps.Single().Activity.ShouldBe(log.Activity);
        }
        public void trace_on_parent()
        {
            var log = new StubbedChainExecutionLog();
            log.RequestTime = 100;

            log.Trace("The trace description", () => log.RequestTime = 175);

            var trace = log.Steps.Single().Log.ShouldBeOfType<Trace>();

            trace.Description.ShouldBe("The trace description");
            trace.Duration.ShouldBe(75);
        }
        public void trace_on_parent()
        {
            var log = new StubbedChainExecutionLog();

            log.RequestTime = 100;

            log.Trace("The trace description", () => log.RequestTime = 175);

            var trace = log.Steps.Single().Log.ShouldBeOfType <Trace>();

            trace.Description.ShouldBe("The trace description");
            trace.Duration.ShouldBe(75);
        }
        public void deep_activity_logging()
        {
            var subject1 = MockRepository.GenerateMock <ISubject>();
            var subject2 = MockRepository.GenerateMock <ISubject>();

            var x1 = new Object();
            var x2 = new Object();
            var x3 = new Object();
            var x4 = new Object();

            var log = new StubbedChainExecutionLog();

            log.RequestTime = 1;
            log.Log(x1);

            log.StartSubject(subject1);
            log.RequestTime = 5;
            log.Log(x2);

            log.RequestTime = 10;
            log.StartSubject(subject2);
            log.Log(x3);

            log.RequestTime = 15;
            log.FinishSubject();
            log.Log(x4);

            var steps = log.Steps.OrderBy(x => x.RequestTime).ToArray();


            steps[0].Activity.Subject.ShouldBe(log);
            steps[1].Activity.Subject.ShouldBe(subject1);

            steps[2].Log.ShouldBe(x3);
            steps[2].Activity.Subject.ShouldBe(subject2);
            steps[3].Activity.Subject.ShouldBe(subject1);
        }
        public void log_exception_once()
        {
            var subject1 = MockRepository.GenerateMock<ISubject>();
            var subject2 = MockRepository.GenerateMock<ISubject>();

            var log = new StubbedChainExecutionLog();
            log.StartSubject(subject1);
            log.StartSubject(subject2);

            var ex = new DivideByZeroException();

            log.LogException(ex);

            log.FinishSubject();
            log.LogException(ex);

            log.FinishSubject();
            log.LogException(ex);



            log.Steps.Select(x => x.Log).OfType<ExceptionReport>()
                .Single().ExceptionText.ShouldBe(ex.ToString());
        }