public async Task Ping_ScalePing_ReturnsExpectedResult(string userAgent, string healthCheckQueryParam, bool underHighLoad, string healthPingEnabled, HttpStatusCode expected) { var httpContext = new DefaultHttpContext(); httpContext.Request.Host = new HostString("local"); httpContext.Request.Method = "Post"; httpContext.Request.Path = "/admin/host/ping"; httpContext.Request.Headers.Add("User-Agent", userAgent); if (healthCheckQueryParam != null) { httpContext.Request.QueryString = new QueryString($"?{ScriptConstants.HealthCheckQueryParam}={healthCheckQueryParam}"); } _hostController.ControllerContext.HttpContext = httpContext; _mockHostPerformanceManager.Setup(p => p.IsUnderHighLoadAsync(It.IsAny <Collection <string> >(), It.IsAny <ILogger>())).ReturnsAsync(() => underHighLoad); if (healthPingEnabled != null) { _mockEnvironment.Setup(p => p.GetEnvironmentVariable(EnvironmentSettingNames.HealthPingEnabled)).Returns(healthPingEnabled); } var result = (StatusCodeResult)(await _hostController.Ping(_mockScriptHostManager.Object)); Assert.Equal((int)expected, result.StatusCode); }