示例#1
0
 public void Test_Log_WithMessage_ShouldLogMessage_MediumPriority_Error()
 {
     //---------------Set up test pack-------------------
     var log = GetMockLog();
     IHabaneroLogger logger = new Log4NetLoggerSpy(log);
     var message = TestUtil.GetRandomString();
     //---------------Assert Precondition----------------
     log.AssertWasNotCalled(log1 => log1.Error(message));
     //---------------Execute Test ----------------------
     logger.Log(message, LogCategory.Exception);
     //---------------Test Result -----------------------
     log.AssertWasCalled(log1 => log1.Error(message));
 }
示例#2
0
        public void Test_Log_WithMessage_ShouldLogMessage_MediumPriority_Error()
        {
            //---------------Set up test pack-------------------
            var             log     = GetMockLog();
            IHabaneroLogger logger  = new Log4NetLoggerSpy(log);
            var             message = TestUtil.GetRandomString();

            //---------------Assert Precondition----------------
            log.AssertWasNotCalled(log1 => log1.Error(message));
            //---------------Execute Test ----------------------
            logger.Log(message, LogCategory.Exception);
            //---------------Test Result -----------------------
            log.AssertWasCalled(log1 => log1.Error(message));
        }
示例#3
0
        public void Test_IsLogging_WhenLogCategoryIsInfo_AndIsFalse_ShouldReturnFalse_Info()
        {
            //---------------Set up test pack-------------------
            var             log    = GetBasicMockLog();
            IHabaneroLogger logger = new Log4NetLoggerSpy(log);

            log.Stub(log2 => log2.IsInfoEnabled).Return(false);
            //---------------Assert Precondition----------------
            log.AssertWasNotCalled(log1 => log1.IsInfoEnabled);
            //---------------Execute Test ----------------------
            var isLogging = logger.IsLogging(LogCategory.Info);

            //---------------Test Result -----------------------
            Assert.IsFalse(isLogging);
            log.AssertWasCalled(log1 => log1.IsInfoEnabled);
        }
示例#4
0
        public void Test_IsLogging_WhenLogCategoryIsException_AndIsTrue_ShouldReturnTrue_Error()
        {
            //---------------Set up test pack-------------------
            var             log    = GetBasicMockLog();
            IHabaneroLogger logger = new Log4NetLoggerSpy(log);

            log.Stub(log2 => log2.IsErrorEnabled).Return(true);
            //---------------Assert Precondition----------------
            log.AssertWasNotCalled(log1 => log1.IsErrorEnabled);
            //---------------Execute Test ----------------------
            var isLogging = logger.IsLogging(LogCategory.Exception);

            //---------------Test Result -----------------------
            Assert.IsTrue(isLogging);
            log.AssertWasCalled(log1 => log1.IsErrorEnabled);
        }
示例#5
0
        public void Test_Log_WithMessageAndLogCategoryIsInfo_AndNotEnabled_ShouldNotLogMessage_Info()
        {
            //---------------Set up test pack-------------------
            var log = GetBasicMockLog();

            log.Stub(log2 => log2.IsInfoEnabled).Return(false);
            IHabaneroLogger logger  = new Log4NetLoggerSpy(log);
            var             message = TestUtil.GetRandomString();

            //---------------Assert Precondition----------------
            log.AssertWasNotCalled(log1 => log1.Info(message));
            //---------------Execute Test ----------------------
            logger.Log(message, LogCategory.Info);
            //---------------Test Result -----------------------
            log.AssertWasNotCalled(log1 => log1.Info(message));
        }
示例#6
0
        public void Test_Log_WithUserException_ShouldLog_Info()
        {
            //---------------Set up test pack-------------------
            var             log       = GetMockLog();
            IHabaneroLogger logger    = new Log4NetLoggerSpy(log);
            var             exception = new UserException();

            //---------------Assert Precondition----------------
            log.AssertWasNotCalled(log1 => log1.Info("", exception));
            Assert.IsInstanceOf <UserException>(exception);
            //---------------Execute Test ----------------------
            logger.Log(exception);
            //---------------Test Result -----------------------
            log.AssertWasCalled(log1 => log1.Info("", exception));
            log.AssertWasNotCalled(log1 => log1.Error("", exception));
        }
示例#7
0
 public void Test_Log_WithMessageAndNonUserException_ShouldLog_Error()
 {
     //---------------Set up test pack-------------------
     var log = GetMockLog();
     IHabaneroLogger logger = new Log4NetLoggerSpy(log);
     var exception = new Exception();
     var message = TestUtil.GetRandomString();
     //---------------Assert Precondition----------------
     log.AssertWasNotCalled(log1 => log1.Error(message, exception));
     Assert.IsNotInstanceOf<UserException>(exception);
     //---------------Execute Test ----------------------
     logger.Log(message, exception);
     //---------------Test Result -----------------------
     log.AssertWasCalled(log1 => log1.Error(message, exception));
     log.AssertWasNotCalled(log1 => log1.Info(message, exception));
 }
示例#8
0
        public void Test_Log_WithMessageAndNonUserException_ShouldLog_Error()
        {
            //---------------Set up test pack-------------------
            var             log       = GetMockLog();
            IHabaneroLogger logger    = new Log4NetLoggerSpy(log);
            var             exception = new Exception();
            var             message   = TestUtil.GetRandomString();

            //---------------Assert Precondition----------------
            log.AssertWasNotCalled(log1 => log1.Error(message, exception));
            Assert.IsNotInstanceOf <UserException>(exception);
            //---------------Execute Test ----------------------
            logger.Log(message, exception);
            //---------------Test Result -----------------------
            log.AssertWasCalled(log1 => log1.Error(message, exception));
            log.AssertWasNotCalled(log1 => log1.Info(message, exception));
        }
示例#9
0
		public void Test_IsLogging_WhenLogCategoryIsInfo_AndIsFalse_ShouldReturnFalse_Info()
		{
			//---------------Set up test pack-------------------
			var log = GetBasicMockLog();
			IHabaneroLogger logger = new Log4NetLoggerSpy(log);
			log.Stub(log2 => log2.IsInfoEnabled).Return(false);
			//---------------Assert Precondition----------------
			log.AssertWasNotCalled(log1 => log1.IsInfoEnabled);
			//---------------Execute Test ----------------------
			var isLogging = logger.IsLogging(LogCategory.Info);
			//---------------Test Result -----------------------
			Assert.IsFalse(isLogging);
			log.AssertWasCalled(log1 => log1.IsInfoEnabled);
		}
示例#10
0
		public void Test_IsLogging_WhenLogCategoryIsException_AndIsTrue_ShouldReturnTrue_Error()
		{
			//---------------Set up test pack-------------------
			var log = GetBasicMockLog();
			IHabaneroLogger logger = new Log4NetLoggerSpy(log);
			log.Stub(log2 => log2.IsErrorEnabled).Return(true);
			//---------------Assert Precondition----------------
			log.AssertWasNotCalled(log1 => log1.IsErrorEnabled);
			//---------------Execute Test ----------------------
			var isLogging = logger.IsLogging(LogCategory.Exception);
			//---------------Test Result -----------------------
			Assert.IsTrue(isLogging);
			log.AssertWasCalled(log1 => log1.IsErrorEnabled);
		}
示例#11
0
		public void Test_Log_WithMessageAndLogCategoryIsInfo_AndNotEnabled_ShouldNotLogMessage_Info()
		{
			//---------------Set up test pack-------------------
			var log = GetBasicMockLog();
			log.Stub(log2 => log2.IsInfoEnabled).Return(false);
			IHabaneroLogger logger = new Log4NetLoggerSpy(log);
			var message = TestUtil.GetRandomString();
			//---------------Assert Precondition----------------
			log.AssertWasNotCalled(log1 => log1.Info(message));
			//---------------Execute Test ----------------------
			logger.Log(message, LogCategory.Info);
			//---------------Test Result -----------------------
			log.AssertWasNotCalled(log1 => log1.Info(message));
		}
示例#12
0
 public void Test_Log_WithUserException_ShouldLog_Info()
 {
     //---------------Set up test pack-------------------
     var log = GetMockLog();
     IHabaneroLogger logger = new Log4NetLoggerSpy(log);
     var exception = new UserException();
     //---------------Assert Precondition----------------
     log.AssertWasNotCalled(log1 => log1.Info("", exception));
     Assert.IsInstanceOf<UserException>(exception);
     //---------------Execute Test ----------------------
     logger.Log(exception);
     //---------------Test Result -----------------------
     log.AssertWasCalled(log1 => log1.Info("", exception));
     log.AssertWasNotCalled(log1 => log1.Error("", exception));
 }