public void InitializeHttpRequestEnvironmentVariables_SetsExpectedVariables() { var environmentVariables = new Dictionary <string, string>(); var headers = new HeaderDictionary(); headers.Add("TEST-A", "a"); headers.Add("TEST-B", "b"); var request = HttpTestHelpers.CreateHttpRequest("GET", "http://test.com/test?a=1&b=2&b=3&c=4", headers); var routeData = new Dictionary <string, object> { { "a", 123 }, { "b", 456 } }; request.HttpContext.Items.Add(HttpExtensionConstants.AzureWebJobsHttpRouteDataKey, routeData); ScriptFunctionInvokerBase.InitializeHttpRequestEnvironmentVariables(environmentVariables, request); Assert.Equal(11, environmentVariables.Count); // verify base request properties Assert.Equal(request.GetDisplayUrl(), environmentVariables["REQ_ORIGINAL_URL"]); Assert.Equal(request.Method.ToString(), environmentVariables["REQ_METHOD"]); Assert.Equal(request.QueryString.ToString(), environmentVariables["REQ_QUERY"]); // verify query parameters Assert.Equal("1", environmentVariables["REQ_QUERY_A"]); Assert.Equal("3", environmentVariables["REQ_QUERY_B"]); Assert.Equal("4", environmentVariables["REQ_QUERY_C"]); // verify headers Assert.Equal("a", environmentVariables["REQ_HEADERS_TEST-A"]); Assert.Equal("b", environmentVariables["REQ_HEADERS_TEST-B"]); Assert.Equal("test.com", environmentVariables["REQ_HEADERS_HOST"]); // verify route parameters Assert.Equal("123", environmentVariables["REQ_PARAMS_A"]); Assert.Equal("456", environmentVariables["REQ_PARAMS_B"]); }
public void InitializeHttpRequestEnvironmentVariables_SetsExpectedVariables() { var environmentVariables = new Dictionary <string, string>(); var request = new HttpRequestMessage(HttpMethod.Get, "http://test.com/test?a=1&b=2&b=3&c=4"); request.Headers.Add("TEST-A", "a"); request.Headers.Add("TEST-B", "b"); var routeData = new Dictionary <string, object> { { "a", 123 }, { "b", 456 } }; request.Properties.Add(ScriptConstants.AzureFunctionsHttpRouteDataKey, routeData); ScriptFunctionInvokerBase.InitializeHttpRequestEnvironmentVariables(environmentVariables, request); Assert.Equal(10, environmentVariables.Count); // verify base request properties Assert.Equal(request.RequestUri.ToString(), environmentVariables["REQ_ORIGINAL_URL"]); Assert.Equal(request.Method.ToString(), environmentVariables["REQ_METHOD"]); Assert.Equal(request.RequestUri.Query.ToString(), environmentVariables["REQ_QUERY"]); // verify query parameters Assert.Equal("1", environmentVariables["REQ_QUERY_A"]); Assert.Equal("3", environmentVariables["REQ_QUERY_B"]); Assert.Equal("4", environmentVariables["REQ_QUERY_C"]); // verify headers Assert.Equal("a", environmentVariables["REQ_HEADERS_TEST-A"]); Assert.Equal("b", environmentVariables["REQ_HEADERS_TEST-B"]); // verify route parameters Assert.Equal("123", environmentVariables["REQ_PARAMS_A"]); Assert.Equal("456", environmentVariables["REQ_PARAMS_B"]); }