예제 #1
0
파일: BZip2Tests.cs 프로젝트: yanivru/avro
        public void CompressDecompress([ValueSource(nameof(_testLengths))] int length, [Values] BZip2Level level)
        {
            byte[] data = Enumerable.Range(0, length).Select(x => (byte)x).ToArray();

            BZip2Codec codec = new BZip2Codec(level);

            byte[] compressed   = codec.Compress(data);
            byte[] uncompressed = codec.Decompress(compressed, compressed.Length);

            Assert.IsTrue(Enumerable.SequenceEqual(data, uncompressed));
        }
예제 #2
0
파일: BZip2Tests.cs 프로젝트: yanivru/avro
        public void CompressDecompressStream([ValueSource(nameof(_testLengths))] int length, [Values] BZip2Level level)
        {
            byte[] data = Enumerable.Range(0, length).Select(x => (byte)x).ToArray();

            BZip2Codec codec = new BZip2Codec(level);

            using (MemoryStream inputStream = new MemoryStream(data))
                using (MemoryStream outputStream = new MemoryStream())
                {
                    codec.Compress(inputStream, outputStream);

                    byte[] compressed   = outputStream.ToArray();
                    byte[] uncompressed = codec.Decompress(compressed, compressed.Length);

                    Assert.IsTrue(Enumerable.SequenceEqual(data, uncompressed));
                }
        }