public void GetBlobContentInSubDirectory() { string ContainerName = Utility.GenNameString("container"); FileUtil.CleanDirectory(downloadDirRoot); List <string> files = FileUtil.GenerateTempFiles(downloadDirRoot, 2); files.Sort(); CloudBlobContainer Container = blobUtil.CreateContainer(ContainerName); try { foreach (string file in files) { string filePath = Path.Combine(downloadDirRoot, file); string blobName = string.Empty; using (var fileStream = System.IO.File.OpenRead(filePath)) { blobName = file; CloudBlockBlob blockBlob = Container.GetBlockBlobReference(blobName); blockBlob.UploadFromStream(fileStream); } } List <IListBlobItem> blobLists = Container.ListBlobs(string.Empty, true, BlobListingDetails.All).ToList(); Test.Assert(blobLists.Count == files.Count, string.Format("container {0} should contain {1} blobs, and actually it contain {2} blobs", ContainerName, files.Count, blobLists.Count)); FileUtil.CleanDirectory(downloadDirRoot); Test.Assert(CommandAgent.DownloadBlobFiles(downloadDirRoot, ContainerName, true), "download blob should be successful"); Test.Assert(CommandAgent.Output.Count == files.Count, "Get-AzureStroageBlobContent should download {0} blobs, and actually it's {1}", files.Count, CommandAgent.Output.Count); for (int i = 0, count = files.Count(); i < count; i++) { string path = Path.Combine(downloadDirRoot, files[i]); CloudBlob blob = blobLists[i] as CloudBlob; if (!File.Exists(path)) { Test.AssertFail(string.Format("local file '{0}' doesn't exist.", path)); } string localMd5 = FileUtil.GetFileContentMD5(path); string convertedName = blobUtil.ConvertBlobNameToFileName(blob.Name, string.Empty); Test.Assert(files[i] == convertedName, string.Format("converted blob name should be {0}, actually it's {1}", files[i], convertedName)); Test.Assert(localMd5 == blob.Properties.ContentMD5, string.Format("blob content md5 should be {0}, and actually it's {1}", localMd5, blob.Properties.ContentMD5)); } } finally { FileUtil.CleanDirectory(downloadDirRoot); blobUtil.RemoveContainer(ContainerName); } }