public void JitStream_Update_wi13899() { int fileCount = 12 + _rnd.Next(16); string dirToZip = "fodder"; var files = TestUtilities.GenerateFilesFlat(dirToZip, fileCount, 100, 72000); OpenDelegate opener = (name) => { TestContext.WriteLine("Opening {0}", name); Stream s = File.OpenRead(Path.Combine(dirToZip,name)); return s; }; CloseDelegate closer = (e, s) => { TestContext.WriteLine("Closing {0}", e); s.Dispose(); }; // Two passes: first to call UpdateEntry() when no prior entry exists. // Second to call UpdateEntry when a prior entry exists. for (int j=0; j < 2; j++) { string zipFileToCreate = String.Format("wi13899-{0}.zip", j); TestContext.WriteLine(""); TestContext.WriteLine("Creating zipfile {0}", zipFileToCreate); if (j!=0) { using (var zip = new ZipFile(zipFileToCreate)) { foreach (var file in files) { zip.AddEntry(Path.GetFileName(file), "This is the content for file " + file); } zip.Save(); } Assert.AreEqual<int>(TestUtilities.CountEntries(zipFileToCreate), files.Length); BasicVerifyZip(zipFileToCreate); TestContext.WriteLine("Updating zipfile {0}", zipFileToCreate); } using (var zip = new ZipFile(zipFileToCreate)) { foreach (var file in files) { zip.UpdateEntry(Path.GetFileName(file), opener, closer); } zip.Save(); } BasicVerifyZip(zipFileToCreate); // verify checksum here? } }
public void Update_MultipleSaves_wi10319() { string zipFileToCreate = "MultipleSaves_wi10319.zip"; using (ZipFile _zipFile = new ZipFile(zipFileToCreate)) { using (MemoryStream data = new MemoryStream()) { using (StreamWriter writer = new StreamWriter(data)) { writer.Write("Dit is een test string."); writer.Flush(); data.Seek(0, SeekOrigin.Begin); _zipFile.AddEntry("test.txt", data); _zipFile.Save(); _zipFile.AddEntry("test2.txt", "Esta es un string de test"); _zipFile.Save(); _zipFile.AddEntry("test3.txt", "this is some content for the entry."); _zipFile.Save(); } } } using (ZipFile _zipFile = new ZipFile(zipFileToCreate)) { using (MemoryStream data = new MemoryStream()) { using (StreamWriter writer = new StreamWriter(data)) { writer.Write("Dit is een andere test string."); writer.Flush(); data.Seek(0, SeekOrigin.Begin); _zipFile.UpdateEntry("test.txt", data); _zipFile.Save(); _zipFile.UpdateEntry("test2.txt", "Esta es un otro string de test"); _zipFile.Save(); _zipFile.UpdateEntry("test3.txt", "This is another string for content."); _zipFile.Save(); } } } }