예제 #1
0
        public static HttpWebRequest PutBlobRequest(BlobContext context, string containerName, string blobName,
                                                    BlobProperties properties, BlobType blobType, byte[] content, long pageBlobSize, AccessCondition accessCondition)
        {
            bool valid = BlobTests.ContainerNameValidator(containerName) &&
                         BlobTests.BlobNameValidator(blobName) &&
                         BlobTests.PutPropertiesValidator(properties) &&
                         BlobTestUtils.ContentValidator(content);

            bool fatal = !BlobTests.PutPropertiesValidator(properties);

            Uri              uri       = BlobTests.ConstructPutUri(context.Address, containerName, blobName);
            HttpWebRequest   request   = null;
            OperationContext opContext = new OperationContext();

            try
            {
                request = BlobHttpWebRequestFactory.Put(uri, context.Timeout, properties, blobType, pageBlobSize, accessCondition, opContext);
                if (fatal)
                {
                    Assert.Fail();
                }
            }
            catch (InvalidOperationException)
            {
                if (valid)
                {
                    Assert.Fail();
                }
            }
            if (valid)
            {
                Assert.IsNotNull(request);
                Assert.IsNotNull(request.Method);
                Assert.AreEqual("PUT", request.Method);
                BlobTestUtils.VersionHeader(request, false);
                BlobTestUtils.ContentTypeHeader(request, null);
                BlobTestUtils.ContentDispositionHeader(request, properties.ContentDisposition);
                BlobTestUtils.ContentEncodingHeader(request, properties.ContentEncoding);
                BlobTestUtils.ContentLanguageHeader(request, null);
                BlobTestUtils.ContentMd5Header(request, null);
                BlobTestUtils.CacheControlHeader(request, null);
                BlobTestUtils.BlobTypeHeader(request, properties.BlobType);
                BlobTestUtils.BlobSizeHeader(request, (properties.BlobType == BlobType.PageBlob) ? properties.Length : (long?)null);
            }
            return(request);
        }