public void TestGzipParsingWithSpaces() { var list = StrategyConfigParser.ParseConfig(" gzip ").ToList(); Assert.AreEqual(1, list.Count); Assert.IsInstanceOf <GZipCompressionStrategy>(list[0]); }
public void TestMultiGzipParsing() { var list = StrategyConfigParser.ParseConfig("gzip;gzip").ToList(); Assert.AreEqual(2, list.Count); Assert.IsInstanceOf <GZipCompressionStrategy>(list[0]); Assert.IsInstanceOf <GZipCompressionStrategy>(list[1]); }
public void TestArithmeticParsing() { var list = StrategyConfigParser.ParseConfig("arithm,456").ToList(); Assert.AreEqual(1, list.Count); Assert.IsInstanceOf <ArithmeticCodingStrategy>(list[0]); Assert.AreEqual(456, ((ArithmeticCodingStrategy)list[0]).InnerChunkSize); }
public void TestExternalParsing() { var list = StrategyConfigParser.ParseConfig("ext,gzip -,gunzip -").ToList(); Assert.AreEqual(1, list.Count); Assert.IsInstanceOf <ExternalCompressionStrategy>(list[0]); var strategy = (ExternalCompressionStrategy)list[0]; Assert.AreEqual("gzip -", strategy.Config.CompressCommand); Assert.AreEqual("gunzip -", strategy.Config.UncompressCommand); }
public static void Main(string[] args) { var brutePackMain = new BrutePackMain(); if (!Parser.Default.ParseArguments(args, brutePackMain)) { return; } var inputFile = brutePackMain.InputFile; var outputFile = brutePackMain.OutputFile; var decompress = brutePackMain.Decompress; if (outputFile == "") { GenerateOutputFilename(inputFile, decompress, out outputFile); } if (!decompress) { if (brutePackMain.ConfigFile.NullOrEmpty() && brutePackMain.ConfigString.NullOrEmpty()) { Console.WriteLine("You must specify -c or -f for compression"); return; } } var inputStream = new FileStream(inputFile, FileMode.Open); var outputStream = new FileStream(outputFile, FileMode.CreateNew); if (decompress) { using (var uncompressStream = new BruteUncompressingStream(new BinaryReader(inputStream))) uncompressStream.CopyTo(outputStream); outputStream.Flush(); outputStream.Close(); } else { var configString = brutePackMain.ConfigFile.NullOrEmpty() ? brutePackMain.ConfigString : File.ReadAllText(brutePackMain.ConfigFile); var parsedConfig = StrategyConfigParser.ParseConfig(configString) .Concat(Enumerable.Repeat <ICompressionStrategy>(new DumbCompressionStrategy(), 1)); var compressingStream = new BruteCompressingStream(new BinaryWriter(outputStream), brutePackMain.MaxBufferSize, new BruteCompressionStrategy(parsedConfig)); inputStream.CopyTo(compressingStream); compressingStream.Flush(); compressingStream.Close(); } }
public void TestMultiEmptyNestedPatterns() { Assert.AreEqual(0, StrategyConfigParser.ParseConfig(",;,").ToList().Count); }
public void TestEmptyPatterns() { Assert.AreEqual(0, StrategyConfigParser.ParseConfig("").ToList().Count); }
public void TestFaultyParsing() { var list = StrategyConfigParser.ParseConfig("top kek").ToList(); }