Esempio n. 1
0
        public void UserAgentContextProviderConstructor2()
        {
            var userAgent       = "SomeUserAgentValue2";
            var contextProvider = new UserAgentContextProvider(userAgent);

            contextProvider.UserAgent.ToString().Should().Be(userAgent);
        }
Esempio n. 2
0
        public void UserAgentContextProviderAddContext()
        {
            var userAgent = "SomeUserAgentValue3";

            var contextProvider = new UserAgentContextProvider(userAgent);
            var logEntry        = new LogEntry();

            contextProvider.AddContext(logEntry);

            logEntry.ExtendedProperties["UserAgent"].Should().Be(userAgent);
        }
Esempio n. 3
0
        public void UserAgentContextProviderConstructor1()
        {
            var userAgent = new StringValues("SomeUserAgentValue1");

            var headers = new RequestHeaders(new HeaderDictionary());

            headers.Set(Microsoft.Net.Http.Headers.HeaderNames.UserAgent, userAgent);

            var requestMock = new Mock <HttpRequest>();

            requestMock.Setup(rm => rm.Headers).Returns(headers.Headers);

            var contextMock = new Mock <HttpContext>();

            contextMock.Setup(cm => cm.Request).Returns(requestMock.Object);

            var accessorMock = new Mock <IHttpContextAccessor>();

            accessorMock.Setup(am => am.HttpContext).Returns(contextMock.Object);

            var contextProvider = new UserAgentContextProvider(accessorMock.Object);

            contextProvider.UserAgent.ToString().Should().Be(userAgent);
        }