public void Test_LoggingEnabled_DebugMode_DebugLevel_SettingsFalse_ReturnsFalse()
        {
            LogSupervisor supervisor = new LogSupervisor();
            supervisor.ModeDetector = new MockModeDetector(true);
            supervisor.SettingsManager =  MockLogSettingsManager.NewSpecified(false);

            bool isEnabled = supervisor.LoggingEnabled(LogLevel.Debug);

            Assert.IsFalse(isEnabled, "Should have been false.");
        }
        public void Test_IsEnabled_MockType_DebugMode_InfoLevel_SettingsTrue_ReturnsTrue()
        {
            LogSupervisor supervisor = new LogSupervisor();
            supervisor.ModeDetector = new MockModeDetector(true);
            supervisor.SettingsManager = MockLogSettingsManager.NewSpecified(true);

            bool isEnabled = supervisor.IsEnabled("MockType", LogLevel.Info);

            Assert.IsTrue(isEnabled, "Should have been true.");
        }
        public void Test_CanPop_False()
        {
            LogGroup logGroup1 = LogGroup.Start("Test");

            LogGroup logGroup2 = LogGroup.Start("Test2");

            logGroup2.Parent = logGroup1;

            LogSupervisor supervisor = new LogSupervisor();
            bool canPop = supervisor.CanPop(logGroup2, logGroup1);

            Assert.IsFalse(canPop);
        }
Beispiel #4
0
        internal void End()
        {
            // Ensure this doesnt run twice for the same group.
            if (!HasEnded)
            {
                LogSupervisor supervisor = new LogSupervisor();

                if (CallingMethod != null && supervisor.IsEnabled(CallingMethod.DeclaringType.Name, LogLevel))
                {
                    // Keep popping groups from the stack until it reaches the correct level
                    // This loop ensures that if a parent group ends before a child group that the child group(s) will be popped
                    // as well and the stack won't become corrupted
                    // TODO: Check if this loop should be moved to DiagnosticState.PopGroup
                    while (supervisor.CanPop(this, DiagnosticState.CurrentGroup))
                    {
                        DiagnosticState.PopGroup();
                    }
                }

                HasEnded = true;
            }
        }
        public void Test_LoggingEnabled_ReleaseMode_InfoLevel_ReturnsTrue()
        {
            LogSupervisor supervisor = new LogSupervisor();
            supervisor.ModeDetector = new MockModeDetector(false);

            bool isEnabled = supervisor.LoggingEnabled(LogLevel.Info);

            Assert.IsTrue(isEnabled, "Should have been true.");
        }
Beispiel #6
0
        internal void End()
        {
            // Ensure this doesnt run twice for the same group.
            if (!HasEnded)
            {
                LogSupervisor supervisor = new LogSupervisor();

                if (CallingMethod != null && supervisor.IsEnabled(CallingMethod.DeclaringType.Name, LogLevel))
                {
                    // Keep popping groups from the stack until it reaches the correct level
                    // This loop ensures that if a parent group ends before a child group that the child group(s) will be popped
                    // as well and the stack won't become corrupted
                    // TODO: Check if this loop should be moved to DiagnosticState.PopGroup
                    while (supervisor.CanPop(this, DiagnosticState.CurrentGroup))
                        DiagnosticState.PopGroup();
                }

                HasEnded = true;

            }
        }