Exemple #1
0
        public void ActivityClosed_Duration_Fixed()
        {
            //-- Arrange

            var log = CreateThreadLog();
            ActivityLogNode activity;

            log.AppendNode(new FormattedLogNode(LogLevel.Info, "One"));
            log.AppendNode(activity = new FormattedActivityLogNode("Two"));

            //-- Act

            Clock.ElapsedMilliseconds = 123;

            activity.Close();

            Clock.ElapsedMilliseconds = 456;

            var rootDuration = log.RootActivity.MillisecondsDuration;
            var childDuration = activity.MillisecondsDuration;

            //-- Assert

            Assert.That(rootDuration, Is.EqualTo(456));
            Assert.That(childDuration, Is.EqualTo(123));
        }
Exemple #2
0
        public void CloseWarningActivity_BubbleUpToParent()
        {
            //-- Arrange

            var log = CreateThreadLog();
            ActivityLogNode activityTwo;
            ActivityLogNode activityFour;

            //-- Act

            log.AppendNode(new FormattedLogNode(LogLevel.Info, "One"));
            log.AppendNode(activityTwo = new FormattedActivityLogNode("Two"));
            log.AppendNode(new FormattedLogNode(LogLevel.Info, "Three"));
            log.AppendNode(activityFour = new FormattedActivityLogNode("Four"));
            log.AppendNode(new FormattedLogNode(LogLevel.Warning, "Five"));

            activityFour.Close();
            var afterFourClosed = ToTestString(log.RootActivity);

            activityTwo.Close();
            var afterTwoClosed = ToTestString(log.RootActivity);

            //-- Assert

            Assert.That(afterFourClosed, Is.EqualTo("AI:Root{LI:One;AW:Two{LI:Three;AW:Four{LW:Five}}}"));
            Assert.That(afterTwoClosed, Is.EqualTo("AW:Root{LI:One;AW:Two{LI:Three;AW:Four{LW:Five}}}"));
        }
Exemple #3
0
        public void CloseActivityNode_ParentBecomesCurrentActivity()
        {
            //-- Arrange

            var log = CreateThreadLog();
            ActivityLogNode activity;

            //-- Act

            log.AppendNode(new FormattedLogNode(LogLevel.Info, "One"));
            log.AppendNode(activity = new FormattedActivityLogNode("Two"));
            log.AppendNode(new FormattedLogNode(LogLevel.Info, "Three"));
            activity.Close();
            log.AppendNode(new FormattedLogNode(LogLevel.Info, "Four"));

            //-- Assert

            Assert.That(ToTestString(log.RootActivity), Is.EqualTo("AI:Root{LI:One;AI:Two{LI:Three};LI:Four}"));
            Assert.That(log.CurrentActivity, Is.SameAs(log.RootActivity));
        }
Exemple #4
0
        public void CloseFailedActivity_BubbleFailureToParent()
        {
            //-- Arrange

            var log = CreateThreadLog();
            ActivityLogNode activityFour;

            //-- Act

            log.AppendNode(new FormattedLogNode(LogLevel.Info, "One"));
            log.AppendNode(new FormattedActivityLogNode("Two"));
            log.AppendNode(new FormattedLogNode(LogLevel.Info, "Three"));
            log.AppendNode(activityFour = new FormattedActivityLogNode("Four"));
            log.AppendNode(new FormattedLogNode(LogLevel.Error, "Five", exception: new Exception()));

            activityFour.Close();

            //-- Assert

            Assert.That(ToTestString(log.RootActivity), Is.EqualTo("AI:Root{LI:One;AEX:Two{LI:Three;AEX:Four{LEX:Five}}}"));
        }
Exemple #5
0
        public void AppendErrorNodeWithException_ClearFailure_FailureBubbledUpAsWarning()
        {
            //-- Arrange

            var log = CreateThreadLog();
            ActivityLogNode activityFour;

            //-- Act

            log.AppendNode(new FormattedLogNode(LogLevel.Info, "One"));
            log.AppendNode(new FormattedActivityLogNode("Two"));
            log.AppendNode(new FormattedLogNode(LogLevel.Info, "Three"));
            log.AppendNode(activityFour = new FormattedActivityLogNode("Four"));
            log.AppendNode(new FormattedLogNode(LogLevel.Error, "Five", exception: new Exception()), clearFailure: true);

            activityFour.Close();

            //-- Assert

            Assert.That(ToTestString(log.RootActivity), Is.EqualTo("AI:Root{LI:One;AW:Two{LI:Three;AW:Four{LEX:Five}}}"));
        }