Exemplo n.º 1
0
        // Deletes any files extracted during the test
        void TestEmptyArchive(ArchiveFile archiveFile, string archiveFilename)
        {
            const string extractDirectory = "./TestExtract";

            Assert.ThrowsException <Exception>(() => archiveFile.GetIndex("TestItem"));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => archiveFile.GetName(0));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => archiveFile.GetSize(0));
            Assert.IsFalse(archiveFile.Contains("TestItem"));

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => archiveFile.OpenStream(0));
            Assert.ThrowsException <ArgumentOutOfRangeException>(() => archiveFile.ExtractFile(0, "Test"));
            archiveFile.ExtractAllFiles(extractDirectory);

            Assert.AreEqual(archiveFilename, archiveFile.GetArchiveFilename());

            Assert.AreEqual(0, archiveFile.GetCount());
            Assert.IsTrue(0 <= archiveFile.GetArchiveFileSize());

            File.Delete(extractDirectory);
        }