Esempio n. 1
0
        public void CabInfoProperties()
        {
            Exception caughtEx;
            CabInfo cabInfo = new CabInfo("test.cab");
            int txtSize = 10240;
            CompressionTestUtil.GenerateRandomFile("test00.txt", 0, txtSize);
            CompressionTestUtil.GenerateRandomFile("test01.txt", 1, txtSize);
            cabInfo.PackFiles(null, new string[] { "test00.txt", "test01.txt" }, null);

            Assert.AreEqual<string>(new FileInfo("test.cab").Directory.FullName, cabInfo.Directory.FullName, "CabInfo.FullName");
            Assert.AreEqual<string>(new FileInfo("test.cab").DirectoryName, cabInfo.DirectoryName, "CabInfo.DirectoryName");
            Assert.AreEqual<long>(new FileInfo("test.cab").Length, cabInfo.Length, "CabInfo.Length");
            Assert.AreEqual<string>("test.cab", cabInfo.Name, "CabInfo.Name");
            Assert.AreEqual<string>(new FileInfo("test.cab").FullName, cabInfo.ToString(), "CabInfo.ToString()");
            cabInfo.CopyTo("test3.cab");
            caughtEx = null;
            try
            {
                cabInfo.CopyTo("test3.cab");
            }
            catch (Exception ex) { caughtEx = ex; }
            Assert.IsInstanceOfType(caughtEx, typeof(IOException), "CabInfo.CopyTo() caught exception: " + caughtEx);
            cabInfo.CopyTo("test3.cab", true);
            cabInfo.MoveTo("test4.cab");
            Assert.AreEqual<string>("test4.cab", cabInfo.Name);
            Assert.IsTrue(cabInfo.Exists, "CabInfo.Exists()");
            Assert.IsTrue(cabInfo.IsValid(), "CabInfo.IsValid");
            cabInfo.Delete();
            Assert.IsFalse(cabInfo.Exists, "!CabInfo.Exists()");
        }