public void ChainReproductability(int maxChars, int minChars = 0, char minChar = ' ', char maxChar = '~') { var dict = HuffmanTreeTests.NumberCharacterGenerator(minChars, maxChars, minChar, maxChar); var w = HuffmanTreeTests.GenerateString(dict); var chain = new HuffmanChain(w); var output = chain.ToString(); TestContext.WriteLine("Original: " + output); var recreated = HuffmanChain.Reconstruct(output); var recreatedString = chain.ToString(); TestContext.WriteLine("Recreated: " + recreatedString); Assert.AreEqual(output, recreatedString); Assert.IsTrue(chain.Equals(recreated)); }
public void ChainReproductabilityFromFile(string path) { var w = File.ReadAllText(path); var chain = new HuffmanChain(w); var chainOutputService = new HuffmanChain.HuffmanChainOutputService(); var chainInputService = new HuffmanChain.HuffmanChainInputService(); var output = chainOutputService.CreateOutput(chain); TestContext.WriteLine("Original: " + output); var recreated = chainInputService.CreateFromInput(output); var recreatedString = chainOutputService.CreateOutput(recreated); TestContext.WriteLine("Recreated: " + recreatedString); Assert.AreEqual(output, recreatedString); Assert.IsTrue(chain.Equals(recreated)); }