public void UnpackingWorks(LzwGifToolsTestCase testCase)
        {
            StreamUnpacker unpacker = new StreamUnpacker(testCase.LzwMinimumCodeSize);
            List <int>     lzwCompressedCodeStream = unpacker.Unpack(testCase.PackedBytes);

            CollectionAssert.AreEqual(testCase.LzwCompressedCodeStream, lzwCompressedCodeStream);
        }
        public void PackingWorks(LzwGifToolsTestCase testCase)
        {
            StreamPacker packer      = new StreamPacker(testCase.LzwMinimumCodeSize);
            List <byte>  packedBytes = packer.Pack(testCase.LzwCompressedCodeStream);

            CollectionAssert.AreEqual(testCase.PackedBytes, packedBytes);
        }
        public void DecodingWorks(LzwGifToolsTestCase testCase)
        {
            Decoder    decoder    = new Decoder(testCase.LzwMinimumCodeSize);
            List <int> codeStream = decoder.Decode(testCase.PackedBytes);

            CollectionAssert.AreEqual(testCase.CodeStream, codeStream);
        }
        public void EncodingWorks(LzwGifToolsTestCase testCase)
        {
            Encoder     encoder     = new Encoder(testCase.LzwMinimumCodeSize);
            List <byte> packedBytes = encoder.Encode(testCase.CodeStream);

            CollectionAssert.AreEqual(testCase.PackedBytes, packedBytes);
        }
        public void LzwEncodingIsReversible(LzwGifToolsTestCase testCase) // and decoding
        {
            LzwCompressor   compressor   = new LzwCompressor(testCase.LzwMinimumCodeSize);
            LzwDecompressor decompressor = new LzwDecompressor(testCase.LzwMinimumCodeSize);

            List <int> lzwCompressedStream   = compressor.Compress(testCase.CodeStream);
            List <int> lzwDecompressedStream = decompressor.Decompress(lzwCompressedStream);

            CollectionAssert.AreEqual(testCase.CodeStream, lzwDecompressedStream);
        }
        public void StreamPackingIsReversible(LzwGifToolsTestCase testCase)
        {
            StreamUnpacker unpacker = new StreamUnpacker(testCase.LzwMinimumCodeSize);
            StreamPacker   packer   = new StreamPacker(testCase.LzwMinimumCodeSize);

            List <int>  lzwCompressedCodeStream = unpacker.Unpack(testCase.PackedBytes);
            List <byte> packedBytes             = new List <byte>();

            packedBytes = packer.Pack(lzwCompressedCodeStream);

            CollectionAssert.AreEqual(testCase.PackedBytes, packedBytes);
        }
        public void AllMethodsWork(LzwGifToolsTestCase testCase)
        {
            LzwCompressor   compressor   = new LzwCompressor(testCase.LzwMinimumCodeSize);
            StreamPacker    packer       = new StreamPacker(testCase.LzwMinimumCodeSize);
            StreamUnpacker  unpacker     = new StreamUnpacker(testCase.LzwMinimumCodeSize);
            LzwDecompressor decompressor = new LzwDecompressor(testCase.LzwMinimumCodeSize);

            List <int>  lzwEncodedCodeStream  = compressor.Compress(testCase.CodeStream);
            List <byte> packedBytes           = packer.Pack(lzwEncodedCodeStream);
            List <int>  lzwEncodedCodeStream2 = unpacker.Unpack(packedBytes);
            List <int>  codeStream            = decompressor.Decompress(lzwEncodedCodeStream2);

            CollectionAssert.AreEqual(testCase.CodeStream, codeStream);
        }
        public void ExportLzwCompressedCodeStreamToTextFile(LzwGifToolsTestCase testCase)
        {
            LzwCompressor compressor          = new LzwCompressor(testCase.LzwMinimumCodeSize);
            List <int>    lzwCompressedStream = compressor.Compress(testCase.CodeStream);

            using (StreamWriter sw = File.CreateText(Config.WorkingDirectory + @"/" + "lzw-compressed-code-stream.txt"))
            {
                int index = 0;

                foreach (int i in lzwCompressedStream)
                {
                    index++;

                    sw.Write(string.Format("{0} ", i));

                    if (index % 8 == 0)
                    {
                        sw.WriteLine("");
                    }
                }
            }
        }