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 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); }
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"); }