public void Do_Not_Log_When_IsExceptionLogDisabled() { var configurationManager = new Mock <IConfigurationManager>(); configurationManager.Setup(c => c.ReadAppSetting("IsExceptionLogEnabled")).Returns("false"); var exceptionLogHandlerMock = ExceptionLogHandlerMock.Create(configurationManager); IExceptionContext exceptionContext = new ExceptionContext(null); exceptionLogHandlerMock.OnException(exceptionContext); exceptionLogHandlerMock.ExceptionLogResolverMock.Verify(e => e.Resolve(exceptionContext), Times.Never()); }
public void Do_Log_When_IsExceptionLogEnabled() { var configurationManager = new Mock <IConfigurationManager>(); configurationManager.Setup(c => c.ReadAppSetting("IsExceptionLogEnabled")).Returns("true"); var exceptionLogHandlerMock = ExceptionLogHandlerMock.Create(configurationManager); IExceptionContext exceptionContext = new ExceptionContext(null); var exceptionLog = new ExceptionLog(); exceptionLogHandlerMock.ExceptionLogResolverMock.Setup(e => e.Resolve(exceptionContext)).Returns(exceptionLog); exceptionLogHandlerMock.OnException(exceptionContext); exceptionLogHandlerMock.ExceptionLogResolverMock.Verify(e => e.Resolve(exceptionContext), Times.Once()); exceptionLogHandlerMock.ExceptionLogRepositoryMock.Verify(e => e.Add(exceptionLog), Times.Once()); }