Beispiel #1
0
        public object Post(SecuredFileUpload request)
        {
            var file = this.RequestContext.Files[0];

            return(new FileUploadResponse {
                FileName = file.FileName,
                ContentLength = file.ContentLength,
                ContentType = file.ContentType,
                Contents = new StreamReader(file.InputStream).ReadToEnd(),
                CustomerId = request.CustomerId,
                CustomerName = request.CustomerName
            });
        }
Beispiel #2
0
        public void PostFileWithRequest_does_work_with_BasicAuth()
        {
            var client  = GetClientWithUserPassword();
            var request = new SecuredFileUpload {
                CustomerId = 123, CustomerName = "Foo"
            };
            var uploadFile = new FileInfo("~/TestExistingDir/upload.html".MapProjectPath());

            var expectedContents = new StreamReader(uploadFile.OpenRead()).ReadToEnd();
            var response         = client.PostFileWithRequest <FileUploadResponse>(ListeningOn + "/securedfileupload", uploadFile, request);

            Assert.That(response.FileName, Is.EqualTo(uploadFile.Name));
            Assert.That(response.ContentLength, Is.EqualTo(uploadFile.Length));
            Assert.That(response.Contents, Is.EqualTo(expectedContents));
            Assert.That(response.CustomerName, Is.EqualTo("Foo"));
            Assert.That(response.CustomerId, Is.EqualTo(123));
        }