예제 #1
0
        public void FixtureSetup()
        {
            Monitor.Enter(monitorObject);
            var assembly         = Assembly.GetAssembly(typeof(ZipArchiveWrap));
            var CurrentDirectory = Path.GetDirectoryName(assembly.Location);

            ArchiveDirectory   = assembly.CodeBase.Substring(8); //remove the "file://" from the front
            ArchiveFileName    = $@"{CurrentDirectory}\ZipArchiveWrapTests.zip";
            ArchiveFileInfo    = new FileInfo(ArchiveFileName);
            UnarchiveDirectory = $@"{CurrentDirectory}\ZipArchiveWrapTests\";

            ArchiveDirectory = $@"{Path.GetDirectoryName(ArchiveDirectory)}\ZipArchiveWrapTestsSource";
            if (!Directory.Exists(ArchiveDirectory))
            {
                Directory.CreateDirectory(ArchiveDirectory);
            }

            File.WriteAllText($@"{ArchiveDirectory}\ZipArchiveWrapTests.txt", "ZipArchiveWrapTests");
            File.WriteAllText($@"{ArchiveDirectory}\AnotherFile.txt", "Another File!");

            if (File.Exists(ArchiveFileName))
            {
                File.Delete(ArchiveFileName);
            }

            zipfile = new ZipFileWrap();
            zipfile.CreateFromDirectory(ArchiveDirectory, ArchiveFileName);

            if (Directory.Exists(UnarchiveDirectory))
            {
                Directory.Delete(UnarchiveDirectory, true);
            }

            zipfile.ExtractToDirectory(ArchiveFileName, UnarchiveDirectory);
        }
예제 #2
0
        public void CreateFromDirectory_WithCompressionLevel_Creates_Archive()
        {
            var instance = new ZipFileWrap();

            instance.CreateFromDirectory(ArchiveDirectory, ArchiveFileName, System.IO.Compression.CompressionLevel.Fastest, true);
            Assert.IsTrue(File.Exists(ArchiveFileName));
            Assert.IsTrue(ArchiveFileInfo.Length > 0);
        }
예제 #3
0
        public void CreateFromDirectory_Creates_Archive()
        {
            var instance = new ZipFileWrap();

            instance.CreateFromDirectory(ArchiveDirectory, ArchiveFileName);
            Assert.IsTrue(File.Exists(ArchiveFileName));
            Assert.IsTrue(ArchiveFileInfo.Length > 0);
        }
예제 #4
0
        public void ExtractToDirectory_WithEncoding_CreatesDirectory()
        {
            var instance = new ZipFileWrap();

            instance.CreateFromDirectory(ArchiveDirectory, ArchiveFileName);
            instance.ExtractToDirectory(ArchiveFileName, UnarchiveDirectory, Encoding.UTF8);
            Assert.IsTrue(Directory.Exists(UnarchiveDirectory));
            Assert.IsTrue(Directory.GetFiles(UnarchiveDirectory).Length > 0);
        }
예제 #5
0
        public void OpenRead_Creates_ZipArchiveWrap()
        {
            var instance = new ZipFileWrap();

            instance.CreateFromDirectory(ArchiveDirectory, ArchiveFileName);
            using (var archive = instance.OpenRead(ArchiveFileName))
            {
                Assert.IsNotNull(archive);
                Assert.IsInstanceOf <ZipArchiveWrap>(archive);
            }
        }
예제 #6
0
        public void Open_Creates_ZipArchiveWrap()
        {
            var instance = new ZipFileWrap();

            instance.CreateFromDirectory(ArchiveDirectory, ArchiveFileName);
            using (var archive = instance.Open(ArchiveFileName, System.IO.Compression.ZipArchiveMode.Read))
            {
                Assert.IsNotNull(archive);
                Assert.IsInstanceOf <ZipArchiveWrap>(archive);
            }
        }