Exemple #1
0
        private async Task <Stream> GetTestReadStreamResult(DataServiceContext dataServiceContext, Document document)
        {
            dataServiceContext.Configurations.RequestPipeline.OnMessageCreating = args =>
            {
                // if we read the wrong link then reply with gibberish
                var resp = (args.RequestUri == document.EntityDescriptor.ReadStreamUri) ? AttachmentResponse : "gibberish";

                return(new CustomizedRequestMessage(
                           args,
                           resp,
                           new Dictionary <string, string>()
                {
                    { "Content-Type", "text/plain" },
                }));
            };

            var streamResponse = await dataServiceContext.GetReadStreamAsync(document, new DataServiceRequestArgs());

            return(streamResponse.Stream);
        }