public void InitializeDoesNotThrowIfRequestIsUnavailable() { var contextAccessor = HttpContextAccessorHelper.CreateHttpContextAccessorWithoutRequest(new HttpContextStub(), new RequestTelemetry()); var initializer = new ClientIpHeaderTelemetryInitializer(contextAccessor); initializer.Initialize(new EventTelemetry()); }
public void InitializeDoesNotThrowIfRequestIsUnavailable() { var contextAccessor = HttpContextAccessorHelper.CreateHttpContextAccessorWithoutRequest(new HttpContextStub(), new RequestTelemetry()); var initializer = new AzureAppServiceRoleNameFromHostNameHeaderInitializer(contextAccessor); initializer.Initialize(new EventTelemetry()); }
public void InitializeDoesNotThrowIfHeaderCollectionIsUnavailable() { var httpContext = new HttpContextStub(); httpContext.OnRequestGetter = () => new HttpRequestStub(httpContext); var contextAccessor = HttpContextAccessorHelper.CreateHttpContextAccessorWithoutRequest(httpContext, new RequestTelemetry()); var initializer = new ClientIpHeaderTelemetryInitializer(contextAccessor); initializer.Initialize(new EventTelemetry()); }
public void InitializeFallsbackToEnvIfRequestIsUnavailable() { try { Environment.SetEnvironmentVariable("WEBSITE_HOSTNAME", "RoleNameEnv"); var contextAccessor = HttpContextAccessorHelper.CreateHttpContextAccessorWithoutRequest(new HttpContextStub(), new RequestTelemetry()); var initializer = new AzureAppServiceRoleNameFromHostNameHeaderInitializer(contextAccessor); var req = new RequestTelemetry(); initializer.Initialize(req); Assert.Equal("RoleNameEnv", req.Context.Cloud.RoleName); } finally { Environment.SetEnvironmentVariable("WEBSITE_HOSTNAME", null); } }