示例#1
0
        public void NullHttpContextRendersEmptyString()
        {
            var renderer = new AspNetApplicationValueLayoutRenderer();

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

            Assert.Empty(result);
        }
        public void VariableNotFoundRendersEmptyString()
        {
            var httpContext = Substitute.For <HttpContextBase>();

            var renderer = new AspNetApplicationValueLayoutRenderer();

            renderer.Variable            = "key";
            renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext);

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

            Assert.Empty(result);
        }
示例#3
0
        public void VariableFoundRendersValue(object expectedValue)
        {
            var httpContext = Substitute.For <HttpContextBase>();

            httpContext.Application["key"].Returns(expectedValue);

            var renderer = new AspNetApplicationValueLayoutRenderer();

            renderer.Variable            = "key";
            renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext);

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

            Assert.Equal(Convert.ToString(expectedValue, CultureInfo.CurrentUICulture), result);
        }