public async Task DeleteDirectoryAsync_DoesNotThrowIfDirectoryDoesNotExist()
        {
            // Arrange
            var directoryName = AzureFileStorageTestHelper.CreateRandomString();

            // Act
            await _sut.DeleteDirectoryAsync(directoryName);
        }
        public async Task DeleteDirectoryAsync_SucceedsIfDirectoryExistsAndEmpty()
        {
            // Arrange
            var directoryName = AzureFileStorageTestHelper.CreateRandomString();
            await AzureFileStorageTestHelper.CreateTestDirectoryAsync(_fileShare, directoryName);

            // Act
            await _sut.DeleteDirectoryAsync(directoryName);

            // Assert
            Assert.False(await AzureFileStorageTestHelper.DirectoryExistsAsync(_fileShare, directoryName));
        }
        public async Task SaveFileAsync_SucceedsForFileInSubDirectory()
        {
            // Arrange
            var fileName = Path.Combine(Path.GetRandomFileName(), Path.GetRandomFileName());

            var contents = AzureFileStorageTestHelper.CreateRandomString();

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(contents)))
            {
                // Act
                await _sut.SaveFileAsync(fileName, stream);
            }
        }
        public async Task SaveFileAsync_SavesCorrectContent()
        {
            // Arrange
            var fileName = Path.GetRandomFileName();

            var expectedContents = AzureFileStorageTestHelper.CreateRandomString();

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(expectedContents)))
            {
                // Act
                await _sut.SaveFileAsync(fileName, stream);
            }

            // Assert
            var actualContents = await AzureFileStorageTestHelper.ReadFileContents(_fileShare, fileName);

            Assert.Equal(expectedContents, actualContents);
        }
        public async Task GetFileStreamAsync_ReturnsFileStreamForFileInSubDirectory()
        {
            // Arrange
            var fileName = Path.Combine(Path.GetRandomFileName(), Path.GetRandomFileName());

            var expectedContents = AzureFileStorageTestHelper.CreateRandomString();

            await AzureFileStorageTestHelper.CreateTestFileAsync(_fileShare, fileName, expectedContents);

            // Act
            using (var stream = await _sut.GetFileStreamAsync(fileName))
                using (var reader = new StreamReader(stream, Encoding.UTF8))
                {
                    var contents = reader.ReadToEnd();

                    // Assert
                    Assert.Equal(expectedContents, contents);
                }
        }
        public async Task DeleteDirectoryAsync_SucceedsIfDirectoryExists()
        {
            // Arrange
            var directoryName = AzureFileStorageTestHelper.CreateRandomString();

            var numberOfFilesToCreate = AzureFileStorageTestHelper.CreateRandomNumber(
                minValue: 1, // Ensure that we always create at least one test file.
                maxValue: byte.MaxValue);

            await AzureFileStorageTestHelper.CreateTestDirectoryAsync(_fileShare, directoryName);

            await AzureFileStorageTestHelper.CreateTestFilesAsync(_fileShare, numberOfFilesToCreate, directoryName);

            // Act
            await _sut.DeleteDirectoryAsync(directoryName);

            // Assert
            Assert.False(await AzureFileStorageTestHelper.DirectoryExistsAsync(_fileShare, directoryName));
        }