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