예제 #1
0
        public void ExceptionLoggerContextWrapper_Simple()
        {
            var exceptionContext = new ExceptionContext(
                new Exception(), ExceptionCatchBlocks.HttpServer,
                new HttpRequestMessage(), new HttpResponseMessage());
            var context = new ExceptionLoggerContext(exceptionContext);

            var wrapper = new ExceptionLoggerContextWrapper(context);

            Assert.Equal("GET", wrapper.GetHttpMethod());
            Assert.Null(wrapper.GetUri());
            Assert.Equal("", wrapper.GetUserAgent());
        }
예제 #2
0
        public void ExceptionLoggerContextWrapper()
        {
            var userAgent      = new ProductInfoHeaderValue("user-agent", "user-agent-value");
            var requestMessage = new HttpRequestMessage();

            requestMessage.Method     = new HttpMethod("POST");
            requestMessage.RequestUri = new Uri("http://google.com/");
            requestMessage.Headers.UserAgent.Add(userAgent);

            var responseMessage = new HttpResponseMessage();

            var exceptionContext = new ExceptionContext(
                new Exception(), ExceptionCatchBlocks.HttpServer, requestMessage, responseMessage);
            var context = new ExceptionLoggerContext(exceptionContext);

            var wrapper = new ExceptionLoggerContextWrapper(context);

            Assert.Equal("POST", wrapper.GetHttpMethod());
            Assert.Equal("http://google.com/", wrapper.GetUri());
            Assert.Equal("user-agent/user-agent-value", wrapper.GetUserAgent());
        }