static private SetUserAndSessionContextForWebRequest ( Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry dependencyTelemetry, |
||
dependencyTelemetry | Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry | Dependency telemetry item. |
webRequest | Http web request. | |
return | void |
public void SetUserAndSessionContextForWebRequestDoesNothingIfTelemetryItemIsNotInitialized() { var webRequest = WebRequest.Create(new Uri("http://bing.com")); var telemetry = new DependencyTelemetry(); string cookieValue = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(webRequest as HttpWebRequest, "ai_session"); Assert.IsNull(cookieValue); WebRequestDependencyTrackingHelpers.SetUserAndSessionContextForWebRequest(telemetry, webRequest); cookieValue = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(webRequest as HttpWebRequest, "ai_session"); Assert.IsNull(cookieValue); }
public void SetCorrelationContextForWebRequestDoesNothingIfOperaitonContextEmpty() { var webRequest = WebRequest.Create(new Uri("http://bing.com")); var telemetry = new DependencyTelemetry(); string rootId = webRequest.Headers[RequestResponseHeaders.StandardRootIdHeader]; string operationId = webRequest.Headers[RequestResponseHeaders.StandardParentIdHeader]; Assert.IsNull(rootId); Assert.IsNull(operationId); WebRequestDependencyTrackingHelpers.SetUserAndSessionContextForWebRequest(telemetry, webRequest); rootId = webRequest.Headers[RequestResponseHeaders.StandardRootIdHeader]; operationId = webRequest.Headers[RequestResponseHeaders.StandardParentIdHeader]; Assert.IsNull(rootId); Assert.IsNull(operationId); }
public void SetUserAndSessionContextForWebRequestSetsCookiesIfTelemetryItemIsInitialized() { var webRequest = WebRequest.Create(new Uri("http://bing.com")); var telemetry = new DependencyTelemetry(); telemetry.Context.Session.Id = "SessionID"; telemetry.Context.User.Id = "UserID"; string cookieValue = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(webRequest as HttpWebRequest, "ai_session"); Assert.IsNull(cookieValue); WebRequestDependencyTrackingHelpers.SetUserAndSessionContextForWebRequest(telemetry, webRequest); cookieValue = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(webRequest as HttpWebRequest, "ai_session"); Assert.IsNotNull(cookieValue); Assert.AreEqual("ai_session=SessionID", cookieValue); cookieValue = DependencyCollectorTestHelpers.GetCookieValueFromWebRequest(webRequest as HttpWebRequest, "ai_user"); Assert.IsNotNull(cookieValue); Assert.AreEqual("ai_user=UserID", cookieValue); }
public void SetUserAndSessionContextForWebRequestDoesNotFailWithNullWebRequest() { var telemetry = new DependencyTelemetry(); WebRequestDependencyTrackingHelpers.SetUserAndSessionContextForWebRequest(telemetry, null); }
public void SetUserAndSessionContextForWebRequestFailsWithNullTelemetry() { var webRequest = WebRequest.Create(new Uri("http://bing.com")); WebRequestDependencyTrackingHelpers.SetUserAndSessionContextForWebRequest(null, webRequest); }