public Task<IRemoteDirectory> GetDirectory(string name) { return Task.Run(() => { IRemoteDirectory directory = new AzureBlobDirectory(_blobContainer.GetDirectoryReference(name)); return directory; }); }
public Task <IRemoteDirectory> GetDirectory(string name) { return(Task.Run(() => { IRemoteDirectory directory = new AzureBlobDirectory(_cloudBlobDirectory.GetDirectoryReference(name)); return directory; })); }
public async Task TestUri() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); const string dirName = "dir"; CloudBlobDirectory directory = await CreateNonEmptyDirectory(container, dirName); AzureBlobDirectory azureBlobDirectory = new AzureBlobDirectory(container.GetDirectoryReference(dirName)); Assert.AreEqual(directory.Uri.ToString(), azureBlobDirectory.Uri); }
public async Task TestDirectories() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); CloudBlobDirectory directory = await CreateNonEmptyDirectory(container, "dir"); await Task.WhenAll( CreateNonEmptyDirectory(directory, "dir1"), CreateNonEmptyDirectory(directory, "dir2")); AzureBlobDirectory azureBlobDirectory = new AzureBlobDirectory(directory); IEnumerable<string> directories = (await azureBlobDirectory.ListDirectories()).Select(d => d.Name); Assert.AreEqual(2, directories.Count()); Assert.IsTrue(directories.Contains("dir1")); Assert.IsTrue(directories.Contains("dir2")); }
public async Task TestFiles() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); CloudBlobDirectory directory = container.GetDirectoryReference("dir"); await Task.WhenAll( CreateEmptyBlob(directory.GetBlockBlobReference("blob1")), CreateEmptyBlob(directory.GetBlockBlobReference("blob2"))); AzureBlobDirectory azureBlobDirectory = new AzureBlobDirectory(directory); IEnumerable<string> files = (await azureBlobDirectory.ListFiles()).Select(d => d.Name); Assert.AreEqual(2, files.Count()); Assert.IsTrue(files.Contains("blob1")); Assert.IsTrue(files.Contains("blob2")); }
public async Task TestDownload() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); CloudBlobDirectory directory = await CreateNonEmptyDirectory(container, "dir"); AzureBlobDirectory azureBlobDirectory = new AzureBlobDirectory(directory); string path = Path.Combine(Path.GetTempPath(), "azureblobdirectorydownloadtest"); if (Directory.Exists(path)) { Directory.Delete(path, recursive: true); } await azureBlobDirectory.Download(path); Assert.IsTrue(Directory.Exists(path)); }
public async Task TestExists() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); await CreateEmptyBlob(container.GetBlockBlobReference("blob1")); CloudBlobDirectory directory = await CreateNonEmptyDirectory(container, "dir"); AzureBlobDirectory azureBlobDirectory = new AzureBlobDirectory(directory); Assert.IsTrue(await azureBlobDirectory.Exists()); await DeleteDirectory(directory); Assert.IsFalse(await azureBlobDirectory.Exists()); }
public async Task TestGetFile() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); CloudBlobDirectory directory = await CreateNonEmptyDirectory(container, "dir"); await CreateEmptyBlob(directory.GetBlockBlobReference("blob1")); AzureBlobDirectory azureBlobDirectory = new AzureBlobDirectory(directory); Assert.AreEqual("blob1", (await azureBlobDirectory.GetFile("blob1")).Name); }