コード例 #1
0
        public void Gzip_Precompressed_Same_As_Write_Switch_CompressionLevel(CompressionLevel startLevel)
        {
            var data = Bytes("I am a compressed chunk of text");

            var ms = new MemoryStream();

            using (var s = new PreCompressedGzipStream(ms, true))
            {
                for (var i = 0; i < 3; ++i)
                {
                    s.CompressionLevel = (CompressionLevel)(((int)startLevel + i) % 3);
                    s.Write(data);
                }
            }
            var expected = PreGzip(s =>
            {
                for (var i = 0; i < 3; ++i)
                {
                    var compressedData = Precompress(data, (CompressionLevel)(((int)startLevel + i) % 3));
                    s.WritePreCompressed(compressedData);
                }
            });

            var returnedData = ms.ToArray();

            Assert.Equal(expected, returnedData);
        }
コード例 #2
0
        public void Gzip_Precompressed_Same_As_Write(CompressionLevel level)
        {
            var data = Bytes("I am a compressed chunk of text");

            var ms = new MemoryStream();

            using (var s = new PreCompressedGzipStream(ms, true))
            {
                s.CompressionLevel = level;
                s.Write(data);
            }
            var expected = PreGzip(s =>
            {
                var compressedData = Precompress(data, level);
                s.WritePreCompressed(compressedData);
            });

            var returnedData = ms.ToArray();

            Assert.Equal(expected, returnedData);
        }