public void CompressDecompressFileTest() { string testPath = Path.Combine( AppDomain.CurrentDomain.BaseDirectory, @"..\..\TestData\"); Assert.IsTrue(FileManager.DeleteAllFilesInFolder( Path.Combine(testPath, "CompressTestFolder"))); Assert.IsTrue(FileManager.DeleteAllFilesInFolder( Path.Combine(testPath, "CompressTestFolder"))); Assert.AreEqual( Directory.GetFiles( Path.Combine(testPath, "CompressTestFolder")).Length, 0); Assert.IsTrue(ZipHelper.DeCompressFiles( Path.Combine(testPath, "Test.zip"), Path.Combine(testPath, "CompressTestFolder"))); Assert.AreEqual(12, Directory.GetFiles( Path.Combine(testPath, "CompressTestFolder")).Length); Assert.IsTrue(ZipHelper.CompressFiles( Path.Combine(testPath, "CompressTestFolder"), Path.Combine(testPath, "TestNew.zip"), false)); Assert.AreEqual( Directory.GetFiles( testPath, "*.zip").Length, 2); Assert.IsTrue(FileManager.DeleteAllFilesInFolder( Path.Combine(testPath, "CompressTestFolder"))); Assert.AreEqual( Directory.GetFiles( Path.Combine(testPath, "CompressTestFolder")).Length, 0); Assert.IsTrue(ZipHelper.DeCompressFiles( Path.Combine(testPath, "TestNew.zip"), Path.Combine(testPath, "CompressTestFolder"))); Assert.AreEqual(12, Directory.GetFiles( Path.Combine(testPath, "CompressTestFolder")).Length); Assert.IsTrue(FileManager.DeleteAllFilesInFolder( testPath, "*New.zip")); Assert.AreEqual( Directory.GetFiles( testPath, "*.zip").Length, 1); Assert.IsTrue(FileManager.DeleteAllFilesInFolder( Path.Combine(testPath, "CompressTestFolder"))); Assert.AreEqual( Directory.GetFiles( Path.Combine(testPath, "CompressTestFolder")).Length, 0); }
/// <summary> /// Put some files into TestData\CompressTestFolder, by unzipping /// TestData\Test.zip. /// </summary> /// <externalUnit/> /// <revision revisor="dev05" date="03/06/09" version="1.0.8.17"> /// Method created. /// </revision> private void PopulateTempPath() { string fileName = Path.Combine(this.basePath, "Test.zip"); ZipHelper.DeCompressFiles(fileName, this.tempPath); }