public void ZipFiles_NoFiles_NoZip() { FileZipper zipper = new FileZipper(); ZipResult zipResult = zipper.ZipFiles(Enumerable.Empty <string>()); Assert.IsNull(zipResult); }
public void ZipFilesThrowsIfCollectionIsEmpty(IEnumerable <FileInfo> files) { Assert.Throws <ArgumentException>(() => { var _ = FileZipper.ZipFiles(files); }); }
public void UnzipFilesThrowsOnNullArgument() { Assert.Throws <ArgumentNullException>(() => { var _ = FileZipper.UnzipFiles(null).ToList(); }); }
public void ZipFilesBoolThrowsIfArgumentIsNull() { Assert.Throws <ArgumentNullException>(() => { var _ = FileZipper.ZipFiles(null, true); }); }
public void Test_GetZipInternalPath() { string fileName = "/SourceDir/File.txt"; string destination = "/DestDir/"; string pattern = fileName + "|" + destination; string zipFileName = "MyZipFile"; // TODO: Remove if not ne //var script = new DummyScript("TestScript"); var zipper = new FileZipper(); string internalPath = zipper.GetZipInternalPath( WorkingDirectory, zipFileName, fileName, pattern ); var expected = zipFileName + "/" + destination.Trim('/') + "/" + Path.GetFileName(fileName); Assert.AreEqual(expected, internalPath, "Wrong path returned."); }
private void ZipFiles() { if (FilesRadioButton.IsChecked == true) { if (string.IsNullOrEmpty(ZipArchivePassword.Password)) { binaryEmbedStruct.ZipFileLocation = new FileInfo(FileZipper.ArchiveFiles(binaryEmbedStruct.Files, null)); } else { binaryEmbedStruct.ZipFileLocation = new FileInfo(FileZipper.ArchiveFiles(binaryEmbedStruct.Files, ZipArchivePassword.Password)); } } else if (DirectoryRadioButton.IsChecked == true) { if (string.IsNullOrEmpty(ZipArchivePassword.Password)) { binaryEmbedStruct.ZipFileLocation = new FileInfo(FileZipper.ArchiveDirectory(binaryEmbedStruct.Directory, null)); } else { binaryEmbedStruct.ZipFileLocation = new FileInfo(FileZipper.ArchiveDirectory(binaryEmbedStruct.Directory, ZipArchivePassword.Password)); } } }
private void compressFile() { if (IsZipFile) { LogWriter.LogInfo("ExportCommand: Compressing the file"); FileZipper.Compress(new FileInfo(FileName)); } }
public void ZipFiles_OneFile_ZipResult() { FileZipper zipper = new FileZipper(); var readme = Path.Combine(GetTestLogDirectoryPath(), "readme.txt"); ZipResult zipResult = zipper.ZipFiles(new[] { readme }); Assert.IsNotNull(zipResult); }
public void ZipArchiveIsCreatedFromValidFiles() { using (var stream = FileZipper.ZipFiles(this.EnumerateFileOfTempCollection())) { File.WriteAllBytes(this.singleZipFile.FullName, stream.ToArray()); Assert.IsTrue(this.singleZipFile.Exists); } }
public void ZipFiles_OneFile_ZipResultContainsFileLog() { FileZipper zipper = new FileZipper(); var readmeTxt = "readme.txt"; var fullPath = Path.Combine(GetTestLogDirectoryPath(), readmeTxt); ZipResult zipResult = zipper.ZipFiles(new[] { fullPath }); Assert.AreEqual(readmeTxt, zipResult.Entries[0]); }
public LibraryGetter( IFileNodeState nodeState ) { NodeState = nodeState; Zipper = new FileZipper(); OnlineZipGetter = new LibraryOnlineZipGetter(nodeState); LocalZipGetter = new LibraryLocalZipGetter(nodeState); NugetGetter = new LibraryNugetGetter(nodeState); }
public void UnizipFilesThrowsIfStreamIsEmpty() { Assert.Throws <ArgumentException>(() => { using (var stream = new MemoryStream()) { var _ = FileZipper.UnzipFiles(stream).ToList(); } }); }
public void SetUp() { sourceDirectoryName = Guid.NewGuid().ToString(); sourceDirectoryPath = Path.Combine(Path.GetTempPath(), sourceDirectoryName); cancellationToken = CancellationToken.None; Directory.CreateDirectory(sourceDirectoryPath); fileZipper = new FileZipper(); }
public void ZipFiles_OneFile_ZipResultContainsFile() { FileZipper zipper = new FileZipper(); var readmeTxt = "readme.txt"; var fullPath = Path.Combine(GetTestLogDirectoryPath(), readmeTxt); ZipResult zipResult = zipper.ZipFiles(new[] { fullPath }); var entry = this.GetEntry(zipResult.ZipStream, readmeTxt); Assert.IsNotNull(entry); }
public void ZipFiles_OneFile_ZipResultContainsFileWithCorrectContent() { FileZipper zipper = new FileZipper(); var readmeTxt = "readme.txt"; var fullPath = Path.Combine(GetTestLogDirectoryPath(), readmeTxt); ZipResult zipResult = zipper.ZipFiles(new[] { fullPath }); var entry = this.GetEntry(zipResult.ZipStream, readmeTxt); StreamReader reader = new StreamReader(entry.GetStream()); string text = reader.ReadToEnd(); Assert.AreEqual("TEST_SUCCESS", text); }
public void ZipFiles_ManyFiles_ZipResultContainsMultipleFileEntries() { var files = Directory.GetFiles(GetTestLogDirectoryPath(), "*.txt"); Assert.Greater(files.Length, 5, "Missing Files for testing"); FileZipper zipper = new FileZipper(); using (ZipResult zipResult = zipper.ZipFiles(files)) { Assert.AreEqual(files.Length, zipResult.Entries.Count()); } }
public FileResult DownloadTestScript() { string zipsolutionPath = Server.MapPath("~/SeleniumTestScript"); FileZipper fz; fz = new FileZipper(); fz.CopyZip(zipsolutionPath, "TestScript.rar"); string solutionPath = zipsolutionPath; solutionPath = zipsolutionPath + "\\TestScript.rar"; if (System.IO.File.Exists(solutionPath)) { byte[] fileBytes = System.IO.File.ReadAllBytes(solutionPath); string fileName = "TestScript.rar"; return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName)); } return(null); }
public void FilesOfArchiveAreWrittenIntoMemory() { var unzippedFiles = new List <FileInfo>(); using (var archive = this.CreateArchiveFromTemporaryFiles()) { foreach (var singleFileStream in FileZipper.UnzipFiles(archive)) { using (singleFileStream) { var path = Path.GetTempFileName(); this.tempTestFiles.AddFile(path, false); File.WriteAllBytes(path, singleFileStream.ToArray()); unzippedFiles.Add(new FileInfo(path)); } } } Assert.IsTrue(unzippedFiles.All(f => f.Exists)); }
/// <summary> /// Creates a new zip archive in memory from the temporary /// files held by this instance /// </summary> /// <returns> /// A <see cref="MemoryStream"/> containing the created zip archive /// </returns> private MemoryStream CreateArchiveFromTemporaryFiles() { return(FileZipper.ZipFiles(this.EnumerateFileOfTempCollection())); }
void decompress() { FileName = FileZipper.Decompress(FileName); }