예제 #1
0
파일: ZipTest.cs 프로젝트: Jeremiahf/wix3
        public void ZipTruncatedArchive()
        {
            ZipInfo zipInfo = new ZipInfo("test-t.zip");
            CompressionTestUtil.GenerateRandomFile("ziptest-0.txt", 0, 5);
            CompressionTestUtil.GenerateRandomFile("ziptest-1.txt", 1, 5);
            zipInfo.PackFiles(null, new string[] { "ziptest-0.txt", "ziptest-1.txt" }, null);

            CompressionTestUtil.TestTruncatedArchive(zipInfo, typeof(ZipException));
        }
예제 #2
0
파일: ZipTest.cs 프로젝트: Jeremiahf/wix3
        public void ZipFileInfoNullParams()
        {
            Exception caughtEx;
            ZipInfo zipInfo = new ZipInfo("test.zip");
            int txtSize = 10240;
            CompressionTestUtil.GenerateRandomFile("test00.txt", 0, txtSize);
            CompressionTestUtil.GenerateRandomFile("test01.txt", 1, txtSize);
            zipInfo.PackFiles(null, new string[] { "test00.txt", "test01.txt" }, null);
            ZipFileInfo zfi = new ZipFileInfo(zipInfo, "test01.txt");

            caughtEx = null;
            try
            {
                new ZipFileInfo(null, "test00.txt");
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException));
            caughtEx = null;
            try
            {
                new ZipFileInfo(zipInfo, null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException));
            caughtEx = null;
            try
            {
                zfi.CopyTo(null);
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(ArgumentNullException));
        }
예제 #3
0
파일: ZipTest.cs 프로젝트: Jeremiahf/wix3
        public void ZipBadUnpackStreamContexts()
        {
            int txtSize = 40960;
            ZipInfo zipInfo = new ZipInfo("test2.zip");
            CompressionTestUtil.GenerateRandomFile("ziptest-0.txt", 0, txtSize);
            CompressionTestUtil.GenerateRandomFile("ziptest-1.txt", 1, txtSize);
            zipInfo.PackFiles(null, new string[] { "ziptest-0.txt", "ziptest-1.txt" }, null);

            using (ZipEngine zipEngine = new ZipEngine())
            {
                CompressionTestUtil.TestBadUnpackStreamContexts(zipEngine, "test2.zip");
            }
        }
예제 #4
0
파일: ZipTest.cs 프로젝트: Jeremiahf/wix3
        public void ZipInfoGetFiles()
        {
            IList<ZipFileInfo> fileInfos;
            ZipInfo zipInfo = new ZipInfo("testgetfiles.zip");

            int txtSize = 10240;
            CompressionTestUtil.GenerateRandomFile("testinfo0.txt", 0, txtSize);
            CompressionTestUtil.GenerateRandomFile("testinfo1.txt", 1, txtSize);
            CompressionTestUtil.GenerateRandomFile("testinfo2.ini", 2, txtSize);
            zipInfo.PackFiles(null, new string[] { "testinfo0.txt", "testinfo1.txt", "testinfo2.ini" }, null);

            fileInfos = zipInfo.GetFiles();
            Assert.IsNotNull(fileInfos);
            Assert.AreEqual<int>(3, fileInfos.Count);
            Assert.AreEqual<string>("testinfo0.txt", fileInfos[0].Name);
            Assert.AreEqual<string>("testinfo1.txt", fileInfos[1].Name);
            Assert.AreEqual<string>("testinfo2.ini", fileInfos[2].Name);

            fileInfos = zipInfo.GetFiles("*.txt");
            Assert.IsNotNull(fileInfos);
            Assert.AreEqual<int>(2, fileInfos.Count);
            Assert.AreEqual<string>("testinfo0.txt", fileInfos[0].Name);
            Assert.AreEqual<string>("testinfo1.txt", fileInfos[1].Name);

            fileInfos = zipInfo.GetFiles("testinfo1.txt");
            Assert.IsNotNull(fileInfos);
            Assert.AreEqual<int>(1, fileInfos.Count);
            Assert.AreEqual<string>("testinfo1.txt", fileInfos[0].Name);
            Assert.IsTrue(DateTime.Now - fileInfos[0].LastWriteTime < TimeSpan.FromMinutes(1),
                "Checking ZipFileInfo.LastWriteTime is current.");
        }