public void ListBlobs_IncludeUncommittedBlobs_ReturnsUncommittedBlobs() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlobUncommitted(containerName, "blob1"); var result = client.ListBlobs(containerName, include: ListBlobsInclude.UncomittedBlobs); Assert.AreEqual(1, result.BlobList.Count); }
public void ListBlobs_BlockAndPageBlobs_ReturnsBothTypes() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob1"); CreatePageBlob(containerName, "blob2"); var result = client.ListBlobs(containerName); Assert.AreEqual(2, result.BlobList.Count); Assert.IsTrue(result.BlobList.Any(b => b.Properties.BlobType == Communications.Common.BlobType.Block)); Assert.IsTrue(result.BlobList.Any(b => b.Properties.BlobType == Communications.Common.BlobType.Page)); }
public void ListBlobs_IncludeCopy_ReturnsCopyStatus() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob1"); CopyBlob(containerName, "blob1", "blob1copy"); var result = client.ListBlobs(containerName, include: ListBlobsInclude.Copy); var copiedBlob = result.BlobList.Where(b => b.Name == "blob1copy").FirstOrDefault(); Assert.IsNotNull(copiedBlob); Assert.IsNotEmpty(copiedBlob.Properties.CopyId); Assert.IsNotNull(copiedBlob.Properties.CopySource); Assert.IsNotEmpty(copiedBlob.Properties.CopyProgress); Assert.IsNotNull(copiedBlob.Properties.CopyStatus); }
public void ListBlobs_IncludeSnapshots_ReturnsSnapshotDetails() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob1"); SnapshotBlob(containerName, "blob1"); var result = client.ListBlobs(containerName, include: ListBlobsInclude.Snapshots); Assert.AreEqual(2, result.BlobList.Count); Assert.IsTrue(result.BlobList.Any(b => b.Snapshot.HasValue)); Assert.IsTrue(result.BlobList.Any(b => !b.Snapshot.HasValue)); }
public void ListBlobs_MarkerSuppliedForLongerList_ReturnsNextSetofResults() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob1"); CreateBlockBlob(containerName, "blob2"); CreateBlockBlob(containerName, "blob3"); var result = client.ListBlobs(containerName, maxResults: 2); var nextMarker = result.NextMarker; var remainingResult = client.ListBlobs(containerName, marker: nextMarker); Assert.AreEqual(1, remainingResult.BlobList.Count); Assert.IsNotNullOrEmpty(remainingResult.Marker); }
public void ListBlobs_IncludeMetadata_ReturnsMetadataInResults() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob1", new Dictionary<string, string>() { { "a", "1"}, { "b", "2"} }); var result = client.ListBlobs(containerName, include: ListBlobsInclude.Metadata); Assert.AreEqual("blob1", result.BlobList[0].Name, "The list blob results did not include the test blob we setup with metadata as the first entry"); Assert.IsNotEmpty(result.BlobList[0].Metadata); Assert.AreEqual(2, result.BlobList[0].Metadata.Count); Assert.IsTrue(result.BlobList[0].Metadata.Any(kvp => kvp.Key == "a" && kvp.Value == "1")); Assert.IsTrue(result.BlobList[0].Metadata.Any(kvp => kvp.Key == "b" && kvp.Value == "2")); }
public void ListBlobs_SmallerMaxResultsThanBlobCount_ReturnsResultsAndContinuationMarker() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob1"); CreateBlockBlob(containerName, "blob2"); CreateBlockBlob(containerName, "blob3"); var result = client.ListBlobs(containerName, maxResults: 2); Assert.AreEqual(2, result.BlobList.Count); Assert.AreEqual(2, result.MaxResults); Assert.IsNotNullOrEmpty(result.NextMarker); }
public void ListBlobs_PrefixAndDelimiterSupplied_ReturnsOnlyBlobsMatchingThatPrefixWithNamesTruncatedAtDelimiter() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob/UnitTest/SampleA"); CreateBlockBlob(containerName, "blob/UnitTest/SampleB"); CreateBlockBlob(containerName, "SomethingElse.txt"); string expectedPrefix = "blob/UnitTest/"; var result = client.ListBlobs(containerName, prefix: expectedPrefix, delimiter: "/"); Assert.AreEqual(2, result.BlobList.Count); Assert.AreEqual(expectedPrefix, result.Prefix); Assert.IsTrue(result.BlobList.Any(b => b.Name == "blob/UnitTest/SampleA")); Assert.IsTrue(result.BlobList.Any(b => b.Name == "blob/UnitTest/SampleB")); }
public void ListBlobs_PrefixSupplied_ReturnsOnlyBlobsMatchingThatPrefix() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob/UnitTest/SampleA"); CreateBlockBlob(containerName, "blob/UnitTest/SampleB"); CreateBlockBlob(containerName, "SomethingElse.txt"); var result = client.ListBlobs(containerName, prefix: "blob"); Assert.AreEqual(2, result.BlobList.Count); Assert.IsTrue(result.BlobList.Any(b => b.Name == "blob/UnitTest/SampleA")); Assert.IsTrue(result.BlobList.Any(b => b.Name == "blob/UnitTest/SampleB")); }
public void ListBlobs_PopulatedContainer_ReturnsExpectedBlobsInList() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); CreateBlockBlob(containerName, "blob/UnitTest/SampleA"); CreateBlockBlob(containerName, "blob/UnitTest/SampleB"); var result = client.ListBlobs(containerName); Assert.AreEqual(2, result.BlobList.Count); Assert.IsTrue(result.BlobList.Any(b => b.Name == "blob/UnitTest/SampleA")); Assert.IsTrue(result.BlobList.Any(b => b.Name == "blob/UnitTest/SampleB")); }
public void ListBlobs_EmptyContainer_ReturnsEmptyList() { IBlobServiceClient client = new BlobServiceClient(AccountSettings); var containerName = GenerateSampleContainerName(); CreateContainer(containerName); var result = client.ListBlobs(containerName); Assert.IsEmpty(result.BlobList); }