예제 #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);
        }
예제 #2
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);
        }
예제 #3
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");
        }