Esempio n. 1
0
        public async Task CreateContainerWorksWithNewName()
        {
            // --- Arrange
            const string CONTAINER = "Container1";
            var          afs       = new AzureFileStorage(STORAGE_IN_APP_CONFIG);
            var          before    = await afs.ContainerExistsAsync(CONTAINER);

            // --- Act

            await afs.CreateContainerAsync("Container1");

            // --- Assert
            before.ShouldBeFalse();
            (await afs.ContainerExistsAsync(CONTAINER)).ShouldBeTrue();
        }
Esempio n. 2
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. 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();
        }