SEBWIN-226: Leveraged new possibility of .NET 4.7 to keep inner stream of GZipStream open.
This commit is contained in:
parent
c02caa6732
commit
90fefae248
2 changed files with 11 additions and 2 deletions
|
@ -83,6 +83,16 @@ namespace SafeExamBrowser.Configuration.UnitTests.DataCompression
|
|||
|
||||
var preview = sut.Peek(compressed, 5);
|
||||
|
||||
try
|
||||
{
|
||||
var position = compressed.Position;
|
||||
var length = compressed.Length;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
Assert.Fail("Source stream was disposed after previewing data!");
|
||||
}
|
||||
|
||||
Assert.AreEqual(5, preview.Length);
|
||||
Assert.IsTrue(Encoding.UTF8.GetBytes("A com").SequenceEqual(preview));
|
||||
}
|
||||
|
|
|
@ -103,10 +103,9 @@ namespace SafeExamBrowser.Configuration.DataCompression
|
|||
|
||||
public byte[] Peek(Stream data, int count)
|
||||
{
|
||||
var stream = new GZipStream(data, CompressionMode.Decompress);
|
||||
|
||||
data.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
using (var stream = new GZipStream(data, CompressionMode.Decompress, true))
|
||||
using (var decompressed = new MemoryStream())
|
||||
{
|
||||
var buffer = new byte[count];
|
||||
|
|
Loading…
Reference in a new issue