public void Decompress_Test() { string hash; byte[] archivedFile; long bufferSize = 20 * 1024 * 1024; using (MD5 md5Hash = MD5.Create()) { hash = Helper.GetMd5Hash(md5Hash, file); } var engine = new CompressEngine(new GZipCompress(), 100); using (MemoryStream original = new MemoryStream(file)) { using (MemoryStream archive = new MemoryStream()) { engine.DoAction(original, archive, bufferSize); archivedFile = archive.ToArray(); } } GZipDecompress gzip = new GZipDecompress(); var originalFile = gzip.DoWork(archivedFile); using (MD5 md5Hash = MD5.Create()) { hash = Helper.GetMd5Hash(md5Hash, originalFile); Assert.IsTrue(Helper.VerifyMd5Hash(md5Hash, file, hash)); } }
public void Compress_Test_CAPACITY_TOTAL_SEGMENTS_5_20() { long bufferSize = 1 * 1024 * 1024; int capacity = 5; byte[] archivedFile; var engine = new CompressEngine(new GZipCompress(), capacity); using (MemoryStream original = new MemoryStream(file)) { using (MemoryStream archive = new MemoryStream()) { engine.DoAction(original, archive, bufferSize); archivedFile = archive.ToArray(); } } }
private void CompressDeCompress(long bufferSize) { byte[] archivedFile; string hash; using (MD5 md5Hash = MD5.Create()) { hash = Helper.GetMd5Hash(md5Hash, file); } var engine = new CompressEngine(new GZipCompress(), capacity); using (MemoryStream original = new MemoryStream(file)) { using (MemoryStream archive = new MemoryStream()) { engine.DoAction(original, archive, bufferSize); archivedFile = archive.ToArray(); } } byte[] dearchivedFile = null; using (MemoryStream archive = new MemoryStream(archivedFile)) { using (MemoryStream original = new MemoryStream()) { DecompressEngine engine2 = new DecompressEngine(new GZipDecompress(), capacity); engine2.DoAction(archive, original, bufferSize); dearchivedFile = original.ToArray(); } } using (MD5 md5Hash = MD5.Create()) { Assert.IsTrue(Helper.VerifyMd5Hash(md5Hash, dearchivedFile, hash)); } }