public void JsonBatchTextualContentTypeTest() { ODataJsonBatchPayloadTestCase testCase = new ODataJsonBatchPayloadTestCase { Description = "Batch request of Textual body and headers in different order.", RequestPayload = @" { ""requests"": [ { ""body"": ""__ENCODED_TEXTUAL_CONTENT__"", ""method"": ""POST"", ""url"": ""http://odata.org/test/Users HTTP/1.1"", ""headers"": { ""Content-Type"": ""text/plain"", ""OData-Version"": ""4.0"" }, ""id"": ""r1"" }, { ""id"": ""r2"", ""method"": ""POST"", ""url"": ""http://odata.org/test/Users HTTP/1.1"", ""headers"": { ""Content-Type"": ""text/*; odata.metadata=minimal"" }, ""body"": ""__ENCODED_TEXTUAL_CONTENT__"" } ] }", RequestMessageDependsOnIdVerifier = null, ContentTypeVerifier = (message, offset) => VerifyOperationRequestMessage(message, offset, new string[] { "r1", "r2" }, new int[] { 2, 1 }) }; testCase.PopulateEncodedContent("__ENCODED_TEXTUAL_CONTENT__", JsonLightUtils.GetJsonEncodedString(textualSampleString)); ServiceProcessBatchRequest(testCase, ODataVersion.V4); }
private string GetEncodedStringContent(BodyContentType bodyContentType, bool forRequest) { string result = null; switch (bodyContentType) { case BodyContentType.Textual: string text = JsonLightUtils.GetJsonEncodedString(forRequest ? this.textualSampleStringA : this.textualSampleStringB); result = string.Format(CultureInfo.InvariantCulture, "\"{0}\"", text); break; case BodyContentType.Binary: byte[] bytes = forRequest ? this.binarySampleBytesA : this.binarySampleBytesB; // Beginning double quote and ending double quote are needed for Json string representation of // base64url-encoded data. result = string.Format(CultureInfo.InvariantCulture, "\"{0}\"", JsonLightUtils.GetBase64UrlEncodedString(bytes)); break; default: break; } return(result); }