public void Deflate_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 PreCompressedDeflateStream(ms, true)) { for (var i = 0; i < 3; ++i) { s.CompressionLevel = (CompressionLevel)(((int)startLevel + i) % 3); s.Write(data); } } var expected = PreDeflate(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); }
public void Deflate_Precompressed_Same_As_Write(CompressionLevel level) { var data = Bytes("I am a compressed chunk of text"); var ms = new MemoryStream(); using (var s = new PreCompressedDeflateStream(ms, true)) { s.CompressionLevel = level; s.Write(data); } var expected = PreDeflate(s => { var compressedData = Precompress(data, level); s.WritePreCompressed(compressedData); }); var returnedData = ms.ToArray(); Assert.Equal(expected, returnedData); }