Beispiel #1
0
        public async Task CreateBlob(string containerName, string blobName, bool isPublic)
        {
            Properties = new BlobProperties()
            {
                BlobType = BlobType.BlockBlob
            };
            HttpRequestMessage request = BlobTests.PutBlobRequest(BlobContext, containerName, blobName, Properties, BlobType.BlockBlob, Content, 0, null);

            Assert.IsTrue(request != null, "Failed to create HttpRequestMessage");

            //HttpRequestHandler.SetContentLength(request, Content.Length);

            CancellationTokenSource timeout = new CancellationTokenSource(30000);

            request.Content = new ByteArrayContent(Content);
            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, BlobContext, timeout))
            {
                HttpStatusCode statusCode        = response.StatusCode;
                string         statusDescription = response.ReasonPhrase;

                if (statusCode != HttpStatusCode.Created)
                {
                    Assert.Fail(string.Format("Failed to create blob: {0}, Status: {1}, Status Description: {2}", containerName, statusCode, statusDescription));
                }
            }
        }
Beispiel #2
0
        public async Task PutBlobScenarioTest(string containerName, string blobName, BlobProperties properties, BlobType blobType, byte[] content, HttpStatusCode?expectedError)
        {
            HttpRequestMessage request = BlobTests.PutBlobRequest(BlobContext, containerName, blobName, properties, blobType, content, content.Length, null);

            request.Content = new ByteArrayContent(content);
            Assert.IsTrue(request != null, "Failed to create HttpRequestMessage");
            //HttpRequestHandler.SetContentLength(request, content.Length);

            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, BlobContext))
            {
                BlobTests.PutBlobResponse(response, BlobContext, expectedError);
            }
        }