public void NullReferrerRendersEmptyString() { var httpContext = Substitute.For <HttpContextBase>(); var renderer = new AspNetRequestReferrerRenderer(); renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext); string result = renderer.Render(new LogEventInfo()); Assert.Empty(result); }
public void ReferrerPresentRenderNonEmptyString() { var httpContext = Substitute.For <HttpContextBase>(); #if !NETSTANDARD_1plus httpContext.Request.UrlReferrer.Returns(new Uri("http://www.google.com/")); #else var headers = new HeaderDict(); headers.Add("Referer", new StringValues("http://www.google.com/")); httpContext.Request.Headers.Returns((callinfo) => headers); #endif var renderer = new AspNetRequestReferrerRenderer(); renderer.HttpContextAccessor = new FakeHttpContextAccessor(httpContext); string result = renderer.Render(new LogEventInfo()); Assert.Equal(result, "http://www.google.com/"); }