public void TestUri() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); Assert.AreEqual(container.Uri.ToString(), azureBlobContainer.Uri); }
public void TestName() { const string containerName = "container"; CloudBlobContainer container = _blobClient.GetContainerReference(containerName); container.CreateIfNotExists(); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); Assert.AreEqual(containerName, azureBlobContainer.Name); }
public async Task TestDirectories() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); await Task.WhenAll( CreateNonEmptyDirectory(container, "dir1"), CreateNonEmptyDirectory(container, "dir2")); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); IEnumerable<string> directories = (await azureBlobContainer.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(); await Task.WhenAll( CreateEmptyBlob(container.GetBlockBlobReference("blob1")), CreateEmptyBlob(container.GetBlockBlobReference("blob2"))); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); IEnumerable<string> files = (await azureBlobContainer.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(); await CreateEmptyBlob(container.GetBlockBlobReference("blob")); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); string path = Path.Combine(Path.GetTempPath(), "azureblobcontainertest"); if (Directory.Exists(path)) { Directory.Delete(path, recursive: true); } await azureBlobContainer.Download(path); Assert.IsTrue(Directory.Exists(path)); }
public async Task TestExists() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); await CreateEmptyBlob(container.GetBlockBlobReference("blob1")); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); Assert.IsTrue(await azureBlobContainer.Exists()); container.Delete(); Assert.IsFalse(await azureBlobContainer.Exists()); }
public async Task TestGetFile() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); await CreateEmptyBlob(container.GetBlockBlobReference("blob1")); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); Assert.AreEqual("blob1", (await azureBlobContainer.GetFile("blob1")).Name); }
public async Task TestGetDirectory() { CloudBlobContainer container = _blobClient.GetContainerReference("container"); container.CreateIfNotExists(); await CreateNonEmptyDirectory(container, "dir1"); AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container); Assert.AreEqual("dir1", (await azureBlobContainer.GetDirectory("dir1")).Name); }