Beispiel #1
0
        public void ShouldLogLogMessageThrowsExceptionForNullLogMessage()
        {
            var interceptor = new StatusCodeInterceptor();

            ILogListener listener = new Mock <ILogListener>().Object;

            interceptor.ShouldLog((LogMessage)null, listener);
        }
Beispiel #2
0
        public void ShouldLogHttpRequestReturnsTrue()
        {
            var interceptor = new StatusCodeInterceptor();

            ILogListener listener = new Mock <ILogListener>().Object;
            bool         result   = interceptor.ShouldLog((HttpRequest)null, listener);

            Assert.AreEqual(true, result);
        }
Beispiel #3
0
        public void ShouldLogFlushLogArgsEvaluatesMinimumResponseHttpStatusCode(int statusCode, bool expectedResult)
        {
            var interceptor = new StatusCodeInterceptor
            {
                MinimumResponseHttpStatusCode = 400
            };

            ILogListener listener     = new Mock <ILogListener>().Object;
            FlushLogArgs flushLogArgs = CommonTestHelpers.Factory.CreateFlushLogArgs();

            flushLogArgs.HttpProperties.Response.SetStatusCode(statusCode);

            bool result = interceptor.ShouldLog(flushLogArgs, listener);

            Assert.AreEqual(expectedResult, result);
        }
Beispiel #4
0
        public void ShouldLogLogMessageEvaluatesMinimumLogMessageLevel(LogLevel logLevel, bool expectedResult)
        {
            var interceptor = new StatusCodeInterceptor
            {
                MinimumLogMessageLevel = LogLevel.Warning
            };

            ILogListener listener = new Mock <ILogListener>().Object;
            LogMessage   message  = new LogMessage(new LogMessage.CreateOptions
            {
                CategoryName = Constants.DefaultLoggerCategoryName,
                LogLevel     = logLevel,
                Message      = "Message"
            });

            bool result = interceptor.ShouldLog(message, listener);

            Assert.AreEqual(expectedResult, result);
        }
Beispiel #5
0
        public void LoggerNotManagedByHttpRequestAlwaysReturnsTrueForShouldLogFlushLogArgs(bool isManagedByHttpRequest)
        {
            var interceptor = new StatusCodeInterceptor
            {
                MinimumResponseHttpStatusCode = 600
            };

            ILogListener listener = new Mock <ILogListener>().Object;

            Logger logger = new Logger();

            logger.DataContainer.LoggerProperties.IsManagedByHttpRequest = isManagedByHttpRequest;

            FlushLogArgs flushLogArgs = FlushLogArgsFactory.Create(new[] { logger });

            bool result         = interceptor.ShouldLog(flushLogArgs, listener);
            bool expectedResult = isManagedByHttpRequest == true ? false : true;

            Assert.AreEqual(expectedResult, result);
        }