Ejemplo n.º 1
0
        public void NullHttpContextRendersEmptyString()
        {
            var renderer = new AspNetSessionIdLayoutRenderer();

            string result = renderer.Render(new LogEventInfo());

            Assert.Empty(result);
        }
Ejemplo n.º 2
0
        public void NullSessionRendersEmptyString()
        {
            var httpContext = Substitute.For<HttpContextBase>();
            httpContext.Session.Returns(null as HttpSessionStateWrapper);

            var renderer = new AspNetSessionIdLayoutRenderer();
            renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext);

            string result = renderer.Render(new LogEventInfo());

            Assert.Empty(result);
        }
Ejemplo n.º 3
0
        public void AvailableSessionRendersSessionId()
        {
            var expectedResult = "value";
            var httpContext = Substitute.For<HttpContextBase>();
            httpContext.Session.SessionID.Returns(expectedResult);

            var renderer = new AspNetSessionIdLayoutRenderer();
            renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext);

            string result = renderer.Render(new LogEventInfo());

            Assert.Equal(expectedResult, result);
        }
Ejemplo n.º 4
0
        public void NullSessionRendersEmptyString()
        {
            var httpContext = Substitute.For <HttpContextBase>();

#if ASP_NET_CORE
            httpContext.Session.Returns(null as Microsoft.AspNetCore.Http.ISession);
#else
            httpContext.Session.Returns(null as HttpSessionStateWrapper);
#endif
            var renderer = new AspNetSessionIdLayoutRenderer();
            renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext);

            string result = renderer.Render(new LogEventInfo());

            Assert.Empty(result);
        }