Skip to content

Commit

Permalink
Test that binary stream is also left open
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Sep 15, 2024
1 parent beb1a8f commit 9e78198
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public void SerializesToBinaryStructure()
KVSerializer.Create(KVSerializationFormat.KeyValues1Binary).Serialize(stream, first);
KVSerializer.Create(KVSerializationFormat.KeyValues1Binary).Serialize(stream, second);
Assert.That(stream.ToArray(), Is.EqualTo(expectedData));
Assert.That(stream.CanRead, Is.True);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public void CreatesTextDocument()
{
KVSerializer.Create(KVSerializationFormat.KeyValues1Text).Serialize(ms, kv);

Assert.That(ms.CanRead, Is.True);
ms.Seek(0, SeekOrigin.Begin);
using var reader = new StreamReader(ms);
text = reader.ReadToEnd();
Expand Down
18 changes: 18 additions & 0 deletions ValveKeyValue/ValveKeyValue.Test/Text/StreamsTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,22 @@ public void LeavesStreamOpenAfterDeserialize()

Assert.That(stream.CanRead, Is.True);
}

[Test]
public void LeavesStreamOpenAfterDeserializeBinary()
{
var data = new byte[]
{
0x00, // object: TestObject
0x54, 0x00,
0x08, // end object
0x08, // end document
};

using var stream = new MemoryStream(data);

KVSerializer.Create(KVSerializationFormat.KeyValues1Binary).Deserialize(stream);

Assert.That(stream.CanRead, Is.True);
}
}

0 comments on commit 9e78198

Please sign in to comment.