Exemplo n.º 1
0
        public void ZipFiles_NoFiles_NoZip()
        {
            FileZipper zipper    = new FileZipper();
            ZipResult  zipResult = zipper.ZipFiles(Enumerable.Empty <string>());

            Assert.IsNull(zipResult);
        }
Exemplo n.º 2
0
 public void ZipFilesThrowsIfCollectionIsEmpty(IEnumerable <FileInfo> files)
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var _ = FileZipper.ZipFiles(files);
     });
 }
Exemplo n.º 3
0
 public void ZipFilesBoolThrowsIfArgumentIsNull()
 {
     Assert.Throws <ArgumentNullException>(() =>
     {
         var _ = FileZipper.ZipFiles(null, true);
     });
 }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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]);
        }
Exemplo n.º 6
0
        public void ZipArchiveIsCreatedFromValidFiles()
        {
            using (var stream = FileZipper.ZipFiles(this.EnumerateFileOfTempCollection()))
            {
                File.WriteAllBytes(this.singleZipFile.FullName, stream.ToArray());

                Assert.IsTrue(this.singleZipFile.Exists);
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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());
            }
        }
Exemplo n.º 10
0
 /// <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()));
 }