Пример #1
0
        public void AssociateTelemetryWithWebRequestDoNotPopulateWebRequestCookiesByDefault()
        {
            this.telemetry.AssociateTelemetryWithWebRequest(this.webRequest);
            string sessionCookie = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(this.webRequest as HttpWebRequest, "ai_session");

            Assert.IsNull(sessionCookie);
            string userCookie = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(this.webRequest as HttpWebRequest, "ai_user");

            Assert.IsNull(userCookie);

            var newTelemetry = new DependencyTelemetry();

            newTelemetry.Context.User.Id    = "UserId";
            newTelemetry.Context.Session.Id = "SessionId";

            // Note, webRequest is already associated with the telemetry. And it should not be overriden.
            newTelemetry.AssociateTelemetryWithWebRequest(this.webRequest);
            sessionCookie = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(this.webRequest as HttpWebRequest, "ai_session");
            Assert.IsNull(sessionCookie);
            userCookie = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(this.webRequest as HttpWebRequest, "ai_user");
            Assert.IsNull(userCookie);
        }