コード例 #1
0
        public void AsyncShouldWriteParameterPayloadInRequestWithoutModelAndWithoutFunctionImport()
        {
            Action <ODataJsonLightOutputContext> test = outputContext =>
            {
                var parameterWriter = new ODataJsonLightParameterWriter(outputContext, operation: null);
                parameterWriter.WriteStartAsync().Wait();
                parameterWriter.WriteValueAsync("primitive", Guid.Empty).Wait();
                parameterWriter.WriteValueAsync("complex", new ODataComplexValue {
                    Properties = new[] { new ODataProperty {
                                             Name = "prop1", Value = 1
                                         } }
                }).Wait();
                var collectionWriter = parameterWriter.CreateCollectionWriterAsync("collection").Result;
                collectionWriter.WriteStartAsync(new ODataCollectionStart()).Wait();
                collectionWriter.WriteItemAsync("item1").Wait();
                collectionWriter.WriteEndAsync().Wait();
                parameterWriter.WriteEndAsync().Wait();
                parameterWriter.FlushAsync().Wait();
            };

            WriteAndValidate(test, "{\"primitive\":\"00000000-0000-0000-0000-000000000000\",\"complex\":{\"prop1\":1},\"collection\":[\"item1\"]}", writingResponse: false, synchronous: false);
        }