Пример #1
0
        public async Task ListContainersScenarioTest(ListingContext listingContext, HttpStatusCode?expectedError, params string[] expectedContainers)
        {
            HttpRequestMessage request = BlobTests.ListContainersRequest(BlobContext, listingContext);

            Assert.IsTrue(request != null, "Failed to create HttpRequestMessage");
            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, BlobContext))
            {
                BlobTests.ListContainersResponse(response, BlobContext, expectedError);
                ListContainersResponse listContainersResponse = await ListContainersResponse.ParseAsync(HttpResponseParsers.GetResponseStream(response), CancellationToken.None);

                int i = 0;
                foreach (BlobContainerEntry item in listContainersResponse.Containers)
                {
                    if (expectedContainers == null)
                    {
                        Assert.Fail("Should not have containers.");
                    }
                    Assert.IsTrue(i < expectedContainers.Length, "Unexpected container: " + item.Name);
                    Assert.AreEqual <string>(expectedContainers[i++], item.Name, "Incorrect container.");
                }
                if (expectedContainers != null && i < expectedContainers.Length)
                {
                    Assert.Fail("Missing container: " + expectedContainers[i] + "(and " + (expectedContainers.Length - i - 1) + " more).");
                }
            }
        }
Пример #2
0
        public async Task BlobProtocolGetContainerWithEmptyHeader()
        {
            ListingContext listingContext = new ListingContext("default", null);
            await cloudOwnerAsync.CreateContainer("emptyheadercontainer", true);

            HttpRequestMessage request = BlobTests.ListContainersRequest(cloudOwnerAsync.BlobContext, listingContext);

            Assert.IsTrue(request != null, "Failed to create HttpRequestMessage");
            if (cloudOwnerAsync.BlobContext.Credentials != null)
            {
                request.Headers.Add("x-ms-blob-application-metadata", "");
            }
            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, cloudOwnerAsync.BlobContext))
            {
                BlobTests.ListContainersResponse(response, cloudOwnerAsync.BlobContext, HttpStatusCode.OK /*HttpStatusCode.Forbidden*/);
            }

            request = BlobTests.ListContainersRequest(cloudOwnerAsync.BlobContext, listingContext);
            Assert.IsTrue(request != null, "Failed to create HttpRequestMessage");
            if (cloudOwnerAsync.BlobContext.Credentials != null)
            {
                request.Headers.Add("x-ms-blob-application-metadata", "");
            }
            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, cloudOwnerAsync.BlobContext))
            {
                BlobTests.ListContainersResponse(response, cloudOwnerAsync.BlobContext, HttpStatusCode.OK);
            }
        }