public void CreateRunscopeRequestWithMultiValueHeaders() { var httpRequestMessage = new HttpRequestMessage() { RequestUri = new Uri("http://example.org") }; httpRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml")); httpRequestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); var message = new RunscopeRequest(httpRequestMessage); var jrequest = message.ToJObject(); var expected = new JObject(new[] { new JProperty("method", "GET"), new JProperty("url", "http://example.org"), new JProperty("headers", new JObject(new [] { new JProperty("Accept", "application/xml, application/json"), })), }); Assert.Equal(expected, jrequest); }
public void CreateRunscopeRequestWithSingleValueHeaders() { var httpRequestMessage = new HttpRequestMessage() { RequestUri = new Uri("http://example.org") }; httpRequestMessage.Headers.Authorization = new AuthenticationHeaderValue("basic", "foo"); httpRequestMessage.Headers.CacheControl = new CacheControlHeaderValue() { MaxAge = new TimeSpan(0, 0, 0, 30) }; var message = new RunscopeRequest(httpRequestMessage); var jrequest = message.ToJObject(); var expected = new JObject(new[] { new JProperty("method", "GET"), new JProperty("url", "http://example.org"), new JProperty("headers", new JObject(new [] { new JProperty("Authorization", "basic foo"), new JProperty("Cache-Control", "max-age=30") })), }); Assert.Equal(expected, jrequest); }
public void CreateRunscopeRequestWithBody() { var httpRequestMessage = new HttpRequestMessage() { RequestUri = new Uri("http://example.org") }; httpRequestMessage.Content = new StringContent("This is some text"); var message = new RunscopeRequest(httpRequestMessage); var jrequest = message.ToJObject(); var expected = new JObject(new[] { new JProperty("method", "GET"), new JProperty("url", "http://example.org"), new JProperty("body", "This is some text"), new JProperty("headers", new JObject(new [] { new JProperty("Content-Type", "text/plain; charset=utf-8"), })) }); Assert.Equal(expected, jrequest); }
public void CreateMinimumRunscopeRequest() { var httpRequestMessage = new HttpRequestMessage() { RequestUri = new Uri("http://example.org") }; var message = new RunscopeRequest(httpRequestMessage); var jrequest = message.ToJObject(); var expected = new JObject(new[] { new JProperty("method", "GET"), new JProperty("url", "http://example.org"), }); Assert.Equal(expected, jrequest); }