Exemplo n.º 1
0
        public static byte[] CompessWithDecompressionHelp(this byte[] value, DecompressionHelpMode mode)
        {
            var compression = new GzipBlockCompression();
            var compressed  = compression.Compress(new Block(value, 1), mode);

            return(compressed.Bytes.ToArray());
        }
Exemplo n.º 2
0
            public void Should_compress_given_block_of_bytes()
            {
                var originalString = TestData.InputFileContent;
                var originalBytes  = originalString.ToArraySegment();
                var block          = new Block(originalBytes, 100);

                var compressedBlock = gzipBlockCompression.Compress(block, DecompressionHelpMode.NoDirtyHacks);

                compressedBlock.Bytes.Should().NotBeEmpty();
                compressedBlock.Bytes.Should().NotBeEquivalentTo(block.Bytes);
                compressedBlock.Bytes.Count.Should().BeLessThan(originalBytes.Count);
                compressedBlock.Bytes.DecompressToString().Should().Be(originalString);
            }
Exemplo n.º 3
0
            public void Should_decompress_given_block_of_bytes()
            {
                var originalString  = TestData.InputFileContent;
                var originalBytes   = originalString.ToArraySegment();
                var compressedBlock = gzipBlockCompression.Compress(new Block(originalBytes, 100), DecompressionHelpMode.NoDirtyHacks);

                var decompressedBlock = gzipBlockCompression.Decompress(compressedBlock);

                decompressedBlock.Offset.Should().Be(100);
                decompressedBlock.Bytes.Should().BeEquivalentTo(originalBytes);
            }