public static void GetBlockListResponse(HttpResponseMessage response, BlobContext context, HttpStatusCode?expectedError) { Assert.IsNotNull(response); if (expectedError == null) { Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, response.ReasonPhrase); BlobTestUtils.ContentTypeHeader(response, "application/xml"); BlobTestUtils.RequestIdHeader(response); } else { Assert.AreEqual(expectedError, response.StatusCode, response.ReasonPhrase); } }
public static HttpRequestMessage 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); HttpRequestMessage request = null; OperationContext opContext = new OperationContext(); try { request = BlobHttpRequestMessageFactory.Put(uri, context.Timeout, properties, blobType, pageBlobSize, null, accessCondition, null, opContext, SharedKeyCanonicalizer.Instance, context.Credentials, null); if (fatal) { Assert.Fail(); } } catch (InvalidOperationException) { if (valid) { Assert.Fail(); } } if (valid) { Assert.IsNotNull(request); Assert.IsNotNull(request.Method); Assert.AreEqual(HttpMethod.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.ContentCrc64Header(request, null); BlobTestUtils.CacheControlHeader(request, null); BlobTestUtils.BlobTypeHeader(request, properties.BlobType); BlobTestUtils.BlobSizeHeader(request, (properties.BlobType == BlobType.PageBlob) ? properties.Length : (long?)null); } return(request); }