public void OptimizeZipThenUnzipTest() { ICopier copier = new Copier(Context); IZipper zipper = new Zipper(Context); IDirectoryFilesLister directoryFilesLister = new DirectoryFilesLister(); StandardPackageDef packageDef = new StandardPackageDef(); DirectorySource test = new DirectorySource(Context, directoryFilesLister, "test", new FullPath("tmp/test")); DirectorySource test2 = new DirectorySource(Context, directoryFilesLister, "test2", new FullPath("tmp/test2")); packageDef.AddFilesSource(test); packageDef.AddFilesSource(test2); CopyProcessor copyProcessor = new CopyProcessor( Context, copier, new FullPath("tmp/output")); copyProcessor .AddTransformation("test", new LocalPath(@"test")) .AddTransformation("test2", new LocalPath(@"test2")); IPackageDef copiedPackageDef = copyProcessor.Process(packageDef); ZipProcessor zipProcessor = new ZipProcessor(Context, zipper, new FileFullPath("tmp/test.zip"), new FullPath("tmp/output"), true, null, "test", "test2"); zipProcessor.Process(copiedPackageDef); string zf = "tmp/test.zip"; using (ZipArchive archive = ZipFile.OpenRead(zf)) { Assert.Equal(4, archive.Entries.Count); var list = archive.Entries.ToList <ZipArchiveEntry>(); Assert.Contains(list, x => x.FullName == $"test2{_seperator}test.txt"); Assert.Contains(list, x => x.FullName == $"test2{_seperator}test2.txt"); Assert.Contains(list, x => x.FullName == $"test{_seperator}test2.txt"); Assert.Contains(list, x => x.FullName == "_zipmetadata.json"); } string unzipPath = "tmp/tt/"; UnzipTask unzip = new UnzipTask(zf, unzipPath); unzip.Execute(Context); var newLine = System.Environment.NewLine; CheckTestFile(Path.Combine(unzipPath, $"test2{_seperator}test.txt"), $"test.txt{newLine}"); CheckTestFile(Path.Combine(unzipPath, $"test2{_seperator}test2.txt"), $"test.txt{newLine}"); CheckTestFile(Path.Combine(unzipPath, $"test{_seperator}test.txt"), $"test.txt{newLine}"); CheckTestFile(Path.Combine(unzipPath, $"test{_seperator}test2.txt"), $"test2.txt{newLine}"); }
public void OptimizeZipThenUnzipTest() { ICopier copier = new Copier(Context); IZipper zipper = new Zipper(Context); IDirectoryFilesLister directoryFilesLister = new DirectoryFilesLister(); StandardPackageDef packageDef = new StandardPackageDef(); DirectorySource test = new DirectorySource(Context, directoryFilesLister, "test", new FullPath("tmp\\test")); DirectorySource test2 = new DirectorySource(Context, directoryFilesLister, "test2", new FullPath("tmp\\test2")); packageDef.AddFilesSource(test); packageDef.AddFilesSource(test2); CopyProcessor copyProcessor = new CopyProcessor( Context, copier, new FullPath("tmp\\output")); copyProcessor .AddTransformation("test", new LocalPath(@"test")) .AddTransformation("test2", new LocalPath(@"test2")); IPackageDef copiedPackageDef = copyProcessor.Process(packageDef); ZipProcessor zipProcessor = new ZipProcessor(Context, zipper, new FileFullPath("tmp\\test.zip"), new FullPath("tmp\\output"), true, null, "test", "test2"); zipProcessor.Process(copiedPackageDef); string zf = "tmp\\test.zip"; using (ZipArchive archive = ZipFile.OpenRead(zf)) { Assert.Equal(4, archive.Entries.Count); Assert.Equal("test2\\test.txt", archive.Entries[1].FullName); Assert.Equal("test2\\test2.txt", archive.Entries[0].FullName); Assert.Equal("test\\test2.txt", archive.Entries[2].FullName); Assert.Equal("_zipmetadata.json", archive.Entries[3].FullName); } string unzipPath = "tmp/tt/"; UnzipTask unzip = new UnzipTask(zf, unzipPath); unzip.Execute(Context); CheckTestFile(Path.Combine(unzipPath, "test2\\test.txt"), "test.txt\r\n"); CheckTestFile(Path.Combine(unzipPath, "test2\\test2.txt"), "test.txt\r\n"); CheckTestFile(Path.Combine(unzipPath, "test\\test.txt"), "test.txt\r\n"); CheckTestFile(Path.Combine(unzipPath, "test\\test2.txt"), "test2.txt\r\n"); }