Example #1
0
 public void FileInfoPartConstructorShouldThrowArgumentNullExceptionWhenNoFileInfo()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var fileInfoPart = new FileInfoPart(null, "file.pdf", "application/pdf");
     });
 }
        public async Task DoWithRefitUsingFileInfoPart()
        {
            using (var fileStream = new FileStream("filename2.txt", FileMode.Create))
            {
                await fileStream.WriteAsync(Encoding.UTF8.GetBytes(FileContent));
            }

            var api = RestService.For <IUploadFile>("http://localhost:5000");

            var fileInfo = new FileInfoPart(new FileInfo("filename2.txt"), "filename.txt");
            HttpResponseMessage response = await api.Upload(fileInfo);

            string responseContent = await response.Content.ReadAsStringAsync();

            Assert.Equal($"filename.txt:{FileContent}", responseContent);
        }
Example #3
0
        /// <inheritdoc />
        public virtual Task <HttpResponseMessage> UploadFileInfoPart(IEnumerable <FileInfoPart> fileInfos, FileInfoPart anotherFile)
        {
            var arguments = new object[] { fileInfos, anotherFile };

            return((Task <HttpResponseMessage>)methodImpls["UploadFileInfoPart"](Client, arguments));
        }
Example #4
0
        /// <inheritdoc />
        public virtual Task <HttpResponseMessage> UploadFileInfoPart(IEnumerable <FileInfoPart> fileInfos, FileInfoPart anotherFile)
        {
            var arguments = new object[] { fileInfos, anotherFile };
            var func      = requestBuilder.BuildRestResultFuncForMethod("UploadFileInfoPart", new Type[] { typeof(IEnumerable <FileInfoPart>), typeof(FileInfoPart) });

            return((Task <HttpResponseMessage>)func(Client, arguments));
        }