예제 #1
0
        public void NullHttpContextRendersEmptyString()
        {
            var renderer = new AspNetSessionIDLayoutRenderer();

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

            Assert.Empty(result);
        }
예제 #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);
        }
예제 #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);
        }