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)); }
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); }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }