public void Open_zip_storage_by_resource() { using var zipStream = new MemoryStream(Resource.TestZip); using var zipStorage = ZipStorgeProvider.CreateStorage(zipStream); var text = zipStorage.ReadAllText("Folder1/File1.txt"); Assert.AreEqual("File1 Text.", text, "The sample file content couldn't be readed properly!"); Assert.IsTrue(zipStorage.StreamExists("Root.txt")); Assert.IsTrue(zipStorage.StorageExists("Folder1")); }
public void Open_zip_storage_and_stream_by_provider() { using var zipStream = GetTempZipStream(); using var zipStorage = ZipStorgeProvider.CreateStorage(zipStream); Assert.IsTrue(zipStorage.StreamExists("file1.txt")); Assert.IsTrue(zipStorage.StreamExists("file4.txt")); Assert.IsTrue(zipStorage.StreamExists("folder1/file2.txt")); Assert.IsTrue(zipStorage.StreamExists("folder_backslash/file.txt")); Assert.IsTrue(zipStorage.StorageExists("folder1/folder2")); Assert.IsFalse(zipStorage.StorageExists("folder1/folder2/file3.txt")); var str = zipStorage.OpenStorage("folder1").OpenStorage("folder2").ReadAllText("file3.txt"); Assert.AreEqual("file3.txt contents.", str, "unexpected text has been readed"); }
public void Open_zip_storage_and_stream_by_ZipArchive_without_directory_entry() { var buf = new byte[10000]; using (var zipArchive = new ZipArchive(new MemoryStream(buf), ZipArchiveMode.Create)) { AddToZipArchive(zipArchive, "folder1/folder1/folder1/file1.zip", "z"); AddToZipArchive(zipArchive, "folder1/folder1/folder1/file2.zip", "z"); } using var zipStream = new MemoryStream(buf); var zipStorage = ZipStorgeProvider.CreateStorage(zipStream); Assert.IsTrue(zipStorage.StorageExists("folder1")); Assert.IsTrue(zipStorage.StorageExists("folder1/folder1")); Assert.IsTrue(zipStorage.StorageExists("folder1/folder1")); Assert.IsTrue(zipStorage.StorageExists("folder1/folder1/folder1")); Assert.IsTrue(zipStorage.StreamExists("folder1/folder1/folder1/file1.zip")); Assert.IsTrue(zipStorage.StreamExists("folder1/folder1/folder1/file2.zip")); var str = zipStorage.ReadAllText("folder1/folder1/folder1/file2.zip"); Assert.AreEqual("z", str, "unexpected text has been readed"); }