public void JsonBatchBinaryContentTypeTest() { ODataJsonBatchPayloadTestCase testCase = new ODataJsonBatchPayloadTestCase { Description = "Batch request of binary body and headers in different order, or content-type header is an empty string.", RequestPayload = @" { ""requests"": [ { ""body"": ""__ENCODED_BINARY_CONTENT__"", ""headers"": { ""Content-Type"": ""my-binary/*"", ""OData-Version"": ""4.0"" }, ""method"": ""POST"", ""url"": ""http://odata.org/test/Users HTTP/1.1"", ""id"": ""r1"" }, { ""id"": ""r2"", ""headers"": { ""Content-Type"": ""my-other-binary/*"" }, ""method"": ""POST"", ""url"": ""http://odata.org/test/Users HTTP/1.1"", ""body"": ""__ENCODED_BINARY_CONTENT__"" }, { ""id"": ""r3"", ""headers"": { ""Content-Type"": """" }, ""method"": ""POST"", ""url"": ""http://odata.org/test/Users HTTP/1.1"", ""body"": ""__ENCODED_BINARY_CONTENT__"" } ] }", RequestMessageDependsOnIdVerifier = null, ContentTypeVerifier = (message, offset) => VerifyOperationRequestMessage( message, offset, new string[] { "r1", "r2", "r3" }, new int[] { 2, 1, 1 }) }; testCase.PopulateEncodedContent("__ENCODED_BINARY_CONTENT__", JsonLightUtils.GetBase64UrlEncodedString(this.binarySampleBytes)); 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); }