public void StandardDecoderDecodeOutput() { //given int[] input = new int[] { 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0 }; MockDecoderFileWriter mockDecoderFileWriter = new MockDecoderFileWriter(); var symbolQuantityDic = new Dictionary <string, ushort>() { { "A", 4 }, { "B", 3 }, { "C", 2 }, { "D", 1 } }; MockDecoderReader mockDecoderReader = new MockDecoderReader(input, symbolQuantityDic); //when StandardHuffmanDecoderInterface standardHuffmanDecoder = new StandardHuffmanDecoderInterface(mockDecoderReader, mockDecoderFileWriter); standardHuffmanDecoder.Decode(); //then mockDecoderFileWriter.AssertEquals(new List <byte>() { (byte)'A', (byte)'B', (byte)'C', (byte)'A', (byte)'B', (byte)'D', (byte)'A', (byte)'B', (byte)'C', (byte)'A' }); }
public void Decode(string inputFilePath, string outputFilePath) { IHuffmanDecoderInterface huffmanDecoderInterface; using (IDecoderReader input = new DecoderReader(inputFilePath)) { IDecoderFileWriter output = new DecoderFileWriter(outputFilePath); if (input.HuffmanEncodeModel == HuffmanEncodeModel.Standard) { huffmanDecoderInterface = new StandardHuffmanDecoderInterface(input, output); } else if (input.HuffmanEncodeModel == HuffmanEncodeModel.Block) { huffmanDecoderInterface = new PairHuffmanDecoderInterface(input, output, input.IsByteCountEven); } else { huffmanDecoderInterface = new MarkowHuffmanDecoderInterface(input, output); } huffmanDecoderInterface.Decode(); output.Save(); } }