Exemplo n.º 1
0
        public decimal GetCompressionRate(Person p, int wordLength, CompressionType type)
        {
            string    fUncompressed = SaveHuffmanEncodedSequence(p, wordLength);
            IArchiver archiver      = GetArchiver(type);

            var    fiToBeCompressed = new FileInfo(fUncompressed);
            string fCompressed      = archiver.Compress(fiToBeCompressed);
            var    fiCompressed     = new FileInfo(fCompressed);

            //compression rate
            if (fiCompressed.Length == 0)
            {
                throw new ArgumentException();
            }

            decimal rate = (decimal)fiToBeCompressed.Length / fiCompressed.Length;


            //remove the files
            fiToBeCompressed.Delete();
            fiCompressed.Delete();

            return(rate);
        }
Exemplo n.º 2
0
 public void CompressWhenInputFolderPathIsNullThrowsArgumentNullException()
 {
     _archiver.Compress(null);
 }