コード例 #1
0
        public void TestUri()
        {
            CloudBlobContainer container = _blobClient.GetContainerReference("container");
            container.CreateIfNotExists();

            AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container);
            Assert.AreEqual(container.Uri.ToString(), azureBlobContainer.Uri);
        }
コード例 #2
0
        public void TestName()
        {
            const string containerName = "container";
            CloudBlobContainer container = _blobClient.GetContainerReference(containerName);
            container.CreateIfNotExists();

            AzureBlobContainer azureBlobContainer = new AzureBlobContainer(container);
            Assert.AreEqual(containerName, azureBlobContainer.Name);
        }
コード例 #3
0
        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"));
        }
コード例 #4
0
        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"));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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);
        }
コード例 #8
0
        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);
        }