public void ValidateRequest_Throws_IfRequestContentTypeDoesNotHaveBoundary() { DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer()); HttpRequestMessage request = new HttpRequestMessage(); request.Content = new StringContent(String.Empty); request.Content.Headers.ContentType = new MediaTypeHeaderValue("multipart/mixed"); HttpResponseException errorResponse = Assert.Throws<HttpResponseException>( () => batchHandler.ValidateRequest(request)); Assert.Equal(HttpStatusCode.BadRequest, errorResponse.Response.StatusCode); Assert.Equal("The batch request must have a boundary specification in the \"Content-Type\" header.", errorResponse.Response.Content.ReadAsAsync<HttpError>().Result.Message); }
public void ValidateRequest_Throws_IfRequestMediaTypeIsWrong() { DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer()); HttpRequestMessage request = new HttpRequestMessage(); request.Content = new StringContent(String.Empty); request.Content.Headers.ContentType = new MediaTypeHeaderValue("text/json"); HttpResponseException errorResponse = Assert.Throws<HttpResponseException>( () => batchHandler.ValidateRequest(request)); Assert.Equal(HttpStatusCode.BadRequest, errorResponse.Response.StatusCode); Assert.Equal("The batch request must have 'multipart/mixed' as the media type.", errorResponse.Response.Content.ReadAsAsync<HttpError>().Result.Message); }
public void ValidateRequest_Throws_IfRequestContentIsNull() { DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer()); HttpRequestMessage request = new HttpRequestMessage(); HttpResponseException errorResponse = Assert.Throws<HttpResponseException>( () => batchHandler.ValidateRequest(request)); Assert.Equal(HttpStatusCode.BadRequest, errorResponse.Response.StatusCode); Assert.Equal("The 'Content' property on the batch request cannot be null.", errorResponse.Response.Content.ReadAsAsync<HttpError>().Result.Message); }
public void ValidateRequest_Throws_IfRequestContentTypeIsNull() { DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer()); HttpRequestMessage request = new HttpRequestMessage(); request.Content = new StringContent(String.Empty); request.Content.Headers.ContentType = null; HttpResponseException errorResponse = Assert.Throws<HttpResponseException>( () => batchHandler.ValidateRequest(request)); Assert.Equal(HttpStatusCode.BadRequest, errorResponse.Response.StatusCode); Assert.Equal("The batch request must have a \"Content-Type\" header.", errorResponse.Response.Content.ReadAsAsync<HttpError>().Result.Message); }
public void ValidateRequest_Throws_IfResponsesIsNull() { DefaultODataBatchHandler batchHandler = new DefaultODataBatchHandler(new HttpServer()); Assert.ThrowsArgumentNull( () => batchHandler.ValidateRequest(null), "request"); }