public void SessionPropertiesAreCopied()
        {
            string sessionId    = $"Session {Guid.NewGuid()}";
            bool   isNewSession = true;

            var session = new Mock <HttpSessionStateBase>();

            session.Setup(p => p.SessionID).Returns(sessionId);
            session.Setup(p => p.IsNewSession).Returns(isNewSession);

            var httpContext = Helpers.MockHttpContext();

            httpContext.Setup(p => p.Session).Returns(session.Object);

            KissLogHttpModule module = new KissLogHttpModule();

            module.PostAcquireRequestState(httpContext.Object);

            var    dictionary = httpContext.Object.Items[LoggerFactory.DictionaryKey] as IDictionary <string, Logger>;
            Logger logger     = dictionary[Constants.DefaultLoggerCategoryName];

            Assert.AreEqual(sessionId, logger.DataContainer.HttpProperties.Request.SessionId);
            Assert.AreEqual(isNewSession, logger.DataContainer.HttpProperties.Request.IsNewSession);
        }
Exemplo n.º 2
0
        public void NotAllowedContentTypeDoesNotLogTheResponseBody(string contentType)
        {
            KissLog.Tests.Common.CommonTestHelpers.ResetContext();

            LoggedFile file = null;

            KissLogConfiguration.Listeners.Add(new KissLog.Tests.Common.CustomLogListener(onFlush: (FlushLogArgs arg) =>
            {
                file = arg.Files.FirstOrDefault();
            }));

            var httpContext = Helpers.MockHttpContext();

            httpContext.Setup(p => p.Response.Headers).Returns(Helpers.GenerateNameValueCollection(new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Content-Type", contentType)
            }));

            KissLogHttpModule module = new KissLogHttpModule();

            module.OnEndRequest(httpContext.Object);

            Assert.IsNull(file);
        }
Exemplo n.º 3
0
        public void ThrowsExceptionForNullHttpContext()
        {
            KissLogHttpModule module = new KissLogHttpModule();

            module.OnPreRequestHandlerExecute(null);
        }
        public void ThrowsExceptionForNullHttpContext()
        {
            KissLogHttpModule module = new KissLogHttpModule();

            module.PostAcquireRequestState(null);
        }
Exemplo n.º 5
0
        public void ThrowsExceptionForNullHttpContext()
        {
            KissLogHttpModule module = new KissLogHttpModule();

            module.OnEndRequest(null);
        }
        public void ThrowsExceptionForNullHttpContext()
        {
            KissLogHttpModule module = new KissLogHttpModule();

            module.OnPostAuthenticateRquest(null);
        }