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 ZipFilesBoolThrowsIfArgumentIsNull() { Assert.Throws <ArgumentNullException>(() => { var _ = FileZipper.ZipFiles(null, true); }); }
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 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 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_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()); } }
/// <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())); }