Exemplo n.º 1
0
 public static void ListSharesResponse(HttpWebResponse response, FileContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, response.StatusDescription);
         FileTestUtils.ContentTypeHeader(response, "application/xml");
         FileTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.StatusDescription);
     }
 }
Exemplo n.º 2
0
 public static void ListFilesAndDirectoriesResponse(HttpResponseMessage response, FileContext context, HttpStatusCode?expectedError)
 {
     Assert.IsNotNull(response);
     if (expectedError == null)
     {
         Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, response.ReasonPhrase);
         FileTestUtils.ContentTypeHeader(response, "application/xml");
         FileTestUtils.RequestIdHeader(response);
     }
     else
     {
         Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase);
     }
 }
Exemplo n.º 3
0
        public static HttpWebRequest PutFileRequest(FileContext context, string shareName, string fileName,
                                                    FileProperties properties, byte[] content, long fileSize, AccessCondition accessCondition)
        {
            bool valid = FileTests.ShareNameValidator(shareName) &&
                         FileTests.FileNameValidator(fileName) &&
                         FileTestUtils.ContentValidator(content);

            Uri              uri       = FileTests.ConstructPutUri(context.Address, shareName, fileName);
            HttpWebRequest   request   = null;
            OperationContext opContext = new OperationContext();

            try
            {
                request = FileHttpWebRequestFactory.Create(uri, context.Timeout, properties, fileSize, accessCondition, true, opContext);
            }
            catch (InvalidOperationException)
            {
                if (valid)
                {
                    Assert.Fail();
                }
            }
            if (valid)
            {
                Assert.IsNotNull(request);
                Assert.IsNotNull(request.Method);
                Assert.AreEqual("PUT", request.Method);
                FileTestUtils.VersionHeader(request, false);
                FileTestUtils.ContentTypeHeader(request, null);
                FileTestUtils.ContentDispositionHeader(request, properties.ContentDisposition);
                FileTestUtils.ContentEncodingHeader(request, properties.ContentEncoding);
                FileTestUtils.ContentLanguageHeader(request, null);
                FileTestUtils.CacheControlHeader(request, null);
                FileTestUtils.FileTypeHeader(request, "File");
                FileTestUtils.FileSizeHeader(request, properties.Length);
            }
            return(request);
        }