|
5 | 5 | using System.Collections.Generic;
|
6 | 6 | using System.IO;
|
7 | 7 | using System.Linq;
|
| 8 | +using System.Net; |
8 | 9 | using System.Net.Http;
|
| 10 | +using System.Net.Http.Headers; |
9 | 11 | using System.Threading.Tasks;
|
| 12 | +using System.Web.Http; |
10 | 13 | using Microsoft.Azure.WebJobs.Script.Tests.ApiHub;
|
11 | 14 | using Microsoft.CodeAnalysis;
|
12 | 15 | using Microsoft.CodeAnalysis.CSharp;
|
@@ -248,6 +251,38 @@ public async Task Scenario_RandGuidBinding_GeneratesRandomIDs()
|
248 | 251 | }
|
249 | 252 | }
|
250 | 253 |
|
| 254 | + [Fact] |
| 255 | + public async Task HttpTrigger_Post_Dynamic() |
| 256 | + { |
| 257 | + var input = new JObject |
| 258 | + { |
| 259 | + { "name", "Mathew Charles" }, |
| 260 | + { "location", "Seattle" } |
| 261 | + }; |
| 262 | + |
| 263 | + HttpRequestMessage request = new HttpRequestMessage |
| 264 | + { |
| 265 | + RequestUri = new Uri(string.Format("http://localhost/api/httptrigger-dynamic")), |
| 266 | + Method = HttpMethod.Post, |
| 267 | + Content = new StringContent(input.ToString()) |
| 268 | + }; |
| 269 | + request.SetConfiguration(new HttpConfiguration()); |
| 270 | + request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); |
| 271 | + |
| 272 | + Dictionary<string, object> arguments = new Dictionary<string, object> |
| 273 | + { |
| 274 | + { "input", request }, |
| 275 | + { ScriptConstants.SystemTriggerParameterName, request } |
| 276 | + }; |
| 277 | + await Fixture.Host.CallAsync("HttpTrigger-Dynamic", arguments); |
| 278 | + |
| 279 | + HttpResponseMessage response = (HttpResponseMessage)request.Properties[ScriptConstants.AzureFunctionsHttpResponseKey]; |
| 280 | + Assert.Equal(HttpStatusCode.OK, response.StatusCode); |
| 281 | + |
| 282 | + string body = await response.Content.ReadAsStringAsync(); |
| 283 | + Assert.Equal("Name: Mathew Charles, Location: Seattle", body); |
| 284 | + } |
| 285 | + |
251 | 286 | public class TestFixture : EndToEndTestFixture
|
252 | 287 | {
|
253 | 288 | private const string ScriptRoot = @"TestScripts\CSharp";
|
|
0 commit comments