Exemple #1
0
        public async Task Compress_ShouldZipFolder()
        {
            var textFilePath = Path.Combine(sourceDirectoryPath, "compress.txt");
            await File.WriteAllTextAsync(textFilePath, "Compress test.");

            zipFilePath = await fileZipper.Compress(sourceDirectoryPath);

            Debugger.Break();

            FileAssert.Exists(zipFilePath);
            FileAssert.ZipHasFiles(zipFilePath, expectedFileCount: 1);
        }
        public async Task Download_ToMemory_ShouldRetrieveObject()
        {
            Console.WriteLine("Downloading {0}:{1}", TestEnvironment.IntegrationTestBucket, TestEnvironment.IntegrationTestResourceName);
            using var fileResponse = await Client.Download(TestEnvironment.IntegrationTestBucket, TestEnvironment.IntegrationTestResourceName, CancellationToken.None);

            var localPath = await fileResponse.WriteToTempFile();

            Console.WriteLine("Downloaded to {0}", localPath);
            Debugger.Break();

            FileAssert.HasContent(localPath);

            DeleteLocalTempFile(localPath);
        }
Exemple #3
0
        public async Task Compress_WithFlatEnabled_ShouldZipFolder()
        {
            await FileTool.CreateTempTextFile(sourceDirectoryPath, "compress.txt", fileContent : "compress");

            var subDirectoryPath = Path.Combine(sourceDirectoryPath, Guid.NewGuid().ToString());

            Directory.CreateDirectory(subDirectoryPath);
            await FileTool.CreateTempTextFile(subDirectoryPath, "compress-sub.txt", fileContent : "compress-sub");

            zipFilePath = await fileZipper.Compress(sourceDirectoryPath, flat : true);

            Debugger.Break();

            FileAssert.Exists(zipFilePath);
            FileAssert.ZipHasFiles(zipFilePath, expectedFileCount: 2);
        }
Exemple #4
0
        public async Task Compress_ShouldZipFilesInMemory()
        {
            var zipFileKey       = $"{sourceDirectoryName}.zip";
            var subDirectoryName = Guid.NewGuid().ToString();
            var fileResponses    = await CreateTempTextFiles(subDirectoryName, "text-file-0.txt", "text-file-1.txt");

            var zipFileResponse = await fileZipper.Compress(zipFileKey, fileResponses, cancellationToken : cancellationToken);

            zipFilePath = Path.Combine(Path.GetTempPath(), zipFileKey);
            await zipFileResponse.WriteTo(zipFilePath);

            log.Debug("Wrote ZIP files to {ZipFilePath}", zipFilePath);
            Debugger.Break();

            FileAssert.ZipHasFiles(zipFilePath, expectedFileCount: 2);
            FileAssert.ZipHasFilesWithName(zipFilePath, entryFileName: $"{subDirectoryName}/text-file-0.txt");
        }