Пример #1
0
        public async Task TestUploadDirectory()
        {
            // First create the file hierarchy on the local file system
            var rootPath = await CreateLocalFileTree(nameof(TestUploadDirectory));

            // Then upload the directory to blob storage
            var container = _blobClient.GetContainerReference("container");

            container.CreateIfNotExists();
            string blobDirPath = $"{nameof(TestUploadDirectory)}/app/1.0.0";
            await BlobUtils.UploadDirectory(rootPath, container, blobDirPath);


            var blobDirectory = container.GetDirectoryReference(blobDirPath);
            var blobs         = await blobDirectory.ListBlobsAsync();

            ISet <string> relativePathSet = new HashSet <string>();

            foreach (var blobItem in blobs)
            {
                var blob    = (CloudBlockBlob)blobItem;
                var relPath = BlobUtils.GetBlobRelativePath(blob, blobDirectory);
                relativePathSet.Add(relPath);
            }

            // Then verify that the hierachy on the blob storage matches the one the local file system
            VerifyThatAllFilesAreThere(relativePathSet, "/");
        }