protected async Task CreateZipFromFileContentListCore() { string methodName = GetTempDirectory(); string dummyFileZip = "dummyZip.zip"; string dummyFolderPath = Utils.CreateDummyDirectory(_mockData.ResourceFolder, methodName, cleanFolder: true); string dummyFileZipPath = Path.Combine(dummyFolderPath, dummyFileZip); List <string> files = new List <string> { Path.Combine(dummyFolderPath, "dummy1.txt"), Path.Combine(dummyFolderPath, "dummy2.txt"), Path.Combine(dummyFolderPath, "dummy3.txt") }; files.ForEach(file => Utils.CreateDummyFile(dummyFolderPath, Path.GetFileName(file), cleanFolder: false)); Zipper.CreateZipFileFromFileListWithFileNameOnly(dummyFileZipPath, files); byte[] bytesOfZip = await KFile.ReadAllBytesAsync(dummyFileZipPath); IList <Core.Support.Pair <string, byte[]> > actualUnzippedFiles = UnZipper.GetFileContentsFromZipFile(bytesOfZip); byte[] bytesOfZipFile = Zipper.CreateZipFromFileContentList(actualUnzippedFiles); IList <Core.Support.Pair <string, byte[]> > expectedUnzippedFiles = UnZipper.GetFileContentsFromZipFile(dummyFileZipPath); Assert.True(expectedUnzippedFiles.Count == actualUnzippedFiles.Count); Utils.RemoveDir(dummyFolderPath); }
protected void CreateZipFileFromFileListWithFileNameOnlyCore() { string tempDir = GetTempDirectory(); string dummyFileZip = "dummy.zip"; string dummyFolderPath = Utils.CreateDummyDirectory(_mockData.ResourceFolder, tempDir, cleanFolder: true); string dummyFileZipPath = Path.Combine(dummyFolderPath, dummyFileZip); List <string> files = new List <string> { Path.Combine(dummyFolderPath, "dummy1.txt"), Path.Combine(dummyFolderPath, "dummy2.txt"), Path.Combine(dummyFolderPath, "dummy3.txt") }; files.ForEach(file => Utils.CreateDummyFile(dummyFolderPath, Path.GetFileName(file), cleanFolder: false)); Zipper.CreateZipFileFromFileListWithFileNameOnly(dummyFileZipPath, files); IList <Pair <string, byte[]> > fileContents = UnZipper.GetFileContentsFromZipFile(dummyFileZipPath); Assert.Equal(fileContents.Count, files.Count); Utils.RemoveDir(dummyFolderPath); }
//protected void WriteAllBytesAsyncCore() //{ // string methodName = GetTempDirectory(); // string dummyFileZip = "dummyZip.zip"; // string dummyFolderPath = Utils.CreateDummyDirectory(_mockData.ResourceFolder, methodName, cleanFolder: true); // string dummyFileZipPath = Path.Combine(dummyFolderPath, dummyFileZip); // List<string> files = new List<string> // { // Path.Combine(dummyFolderPath, "dummy1.txt"), // Path.Combine(dummyFolderPath, "dummy2.txt"), // Path.Combine(dummyFolderPath, "dummy3.txt") // }; // files.ForEach(file => Utils.CreateDummyFile(dummyFolderPath, Path.GetFileName(file), cleanFolder: false)); // Zipper.CreateZipFileFromFileListWithFileNameOnly(dummyFileZipPath, files); // Directory.CreateDirectory(Path.Combine(dummyFolderPath , "dummy")); // byte[] bytesOfZippedFolder = Zipper.CreateZipContentFromFolder(dummyFolderPath, Path.Combine(dummyFolderPath , "dummy"), "*.txt", false); // IList<Pair<string, byte[]>> fileContents = UnZipper.GetFileContentsFromZipFile(bytesOfZippedFolder); // Assert.False(true); // Utils.RemoveDir(dummyFolderPath); //} //protected async Task UnZipSingleFileContentToStreamCore() //{ // string methodName = GetTempDirectory(); // string dummyFileZip = "dummyZip.zip"; // string dummyFolderPath = Utils.CreateDummyDirectory(_mockData.ResourceFolder, methodName, cleanFolder: true); // string dummyFileZipPath = Path.Combine(dummyFolderPath, dummyFileZip); // List<string> files = new List<string> // { // Path.Combine(dummyFolderPath, "dummy1.txt"), // }; // files.ForEach(file => Utils.CreateDummyFile(dummyFolderPath, Path.GetFileName(file), cleanFolder: false)); // Zipper.CreateZipFileFromFileListWithFileNameOnly(dummyFileZipPath, files); // byte[] fileContent = await KFile.ReadAllBytesAsync(dummyFileZipPath); // using (MemoryStream ms = new MemoryStream()) // { // Zipper.UnZipSingleFileContentToStream(fileContent, ms); // byte[] bytesOfStream = ms.ToArray(); // await KFile.WriteAllBytesAsync(Path.Combine(dummyFolderPath, "dummy.zip"), bytesOfStream).ConfigureAwait(false); // } // IList<Pair<string, byte[]>> fileContents = UnZipper.GetFileContentsFromZipFile(Path.Combine(dummyFolderPath, "dummy.zip")); // Assert.False(true); // Utils.RemoveDir(dummyFolderPath); //} protected async Task UnzipDllsFromNupkgFileCore() { string methodName = GetTempDirectory(); string dummyFileZip = "dummyZip.zip"; string dummyFolderPath = Utils.CreateDummyDirectory(_mockData.ResourceFolder, methodName, cleanFolder: true); string dummyFileZipPath = Path.Combine(dummyFolderPath, dummyFileZip); List <string> files = new List <string> { Path.Combine(dummyFolderPath, "dummy1.txt"), Path.Combine(dummyFolderPath, "dummy2.txt"), Path.Combine(dummyFolderPath, "dummy3.txt") }; files.ForEach(file => Utils.CreateDummyFile(dummyFolderPath, Path.GetFileName(file), cleanFolder: false)); Zipper.CreateZipFileFromFileListWithFileNameOnly(dummyFileZipPath, files); string unzipDirectory = Utils.CreateDummyDirectory(dummyFolderPath, "dummy", cleanFolder: true); await UnZipper.ExtractFlatFilesFromZipFile(dummyFileZipPath, unzipDirectory, "*.txt"); Assert.Equal(Directory.GetFiles(unzipDirectory).Length, files.Count); Utils.RemoveDir(dummyFolderPath); }