Esempio n. 1
0
        public async Task RemoveContainerFailsWithNonEmptyContainer()
        {
            // --- Arrange
            const string CONTAINER = "NonEmptyContainer";
            const string FOLDER    = @"C:\Temp\AbstractFiles";
            var          afs       = new AzureFileStorage(STORAGE_IN_APP_CONFIG);
            await afs.CreateContainerAsync("Container7");

            await afs.CreateContainerAsync(CONTAINER);

            if (!Directory.Exists(FOLDER))
            {
                Directory.CreateDirectory(FOLDER);
            }
            var filePath = Path.Combine(FOLDER, "file.txt");

            File.WriteAllText(filePath, "TextContents");
            var blobClient = afs.StorageAccount.CreateCloudBlobClient();
            var container  = blobClient.GetContainerReference(CONTAINER.ToLower());
            var blockBlob  = container.GetBlockBlobReference("myblob1");

            using (var fileStream = File.OpenRead(filePath))
            {
                blockBlob.UploadFromStream(fileStream);
            }

            // --- Act
            var removed = await afs.RemoveContainerAsync(CONTAINER);

            // --- Assert
            removed.ShouldBeTrue();
            (await afs.ContainerExistsAsync(CONTAINER)).ShouldBeFalse();
        }
Esempio n. 2
0
        private static void RemoveContainers()
        {
            var afs = new AzureFileStorage(STORAGE_IN_APP_CONFIG);

            Task.WaitAll(
                afs.RemoveContainerAsync("Container1", true),
                afs.RemoveContainerAsync("Container2", true),
                afs.RemoveContainerAsync("Container3", true),
                afs.RemoveContainerAsync("Container4", true),
                afs.RemoveContainerAsync("Container5", true),
                afs.RemoveContainerAsync("Container6", true),
                afs.RemoveContainerAsync("Container7", true),
                afs.RemoveContainerAsync("EmptyContainer", true),
                afs.RemoveContainerAsync("NonEmptyContainer", true));
        }
Esempio n. 3
0
        public async Task RemoveContainerWorksWithNonExistingContainer()
        {
            // --- Arrange
            const string CONTAINER = "NonExisting";
            var          afs       = new AzureFileStorage(STORAGE_IN_APP_CONFIG);
            await afs.CreateContainerAsync("Container5");

            // --- Act
            var removed = await afs.RemoveContainerAsync(CONTAINER);

            // --- Assert
            removed.ShouldBeFalse();
            (await afs.ContainerExistsAsync(CONTAINER)).ShouldBeFalse();
        }