Ejemplo n.º 1
0
        public async Task ListBlobsScenarioTest(string containerName, BlobListingContext listingContext, HttpStatusCode?expectedError, params string[] expectedBlobs)
        {
            HttpRequestMessage request = BlobTests.ListBlobsRequest(BlobContext, containerName, listingContext);

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

            using (HttpResponseMessage response = await BlobTestUtils.GetResponse(request, BlobContext))
            {
                BlobTests.ListBlobsResponse(response, BlobContext, expectedError);
                ListBlobsResponse listBlobsResponse = await ListBlobsResponse.ParseAsync(HttpResponseParsers.GetResponseStream(response), CancellationToken.None);

                int i = 0;
                foreach (IListBlobEntry item in listBlobsResponse.Blobs)
                {
                    ListBlobEntry blob = item as ListBlobEntry;
                    if (expectedBlobs == null)
                    {
                        Assert.Fail("Should not have blobs.");
                    }
                    Assert.IsTrue(i < expectedBlobs.Length, "Unexpected blob: " + blob.Name);
                    Assert.AreEqual <string>(expectedBlobs[i++], blob.Name, "Incorrect blob.");
                }
                if (expectedBlobs != null && i < expectedBlobs.Length)
                {
                    Assert.Fail("Missing blob: " + expectedBlobs[i] + "(and " + (expectedBlobs.Length - i - 1) + " more).");
                }
            }
        }