-Changed BsonReader/BsonWriter to close the underlying stream by default when closed
-Added CloseInput/CloseOutput to JsonReader/JsonWriter to control whether the underlying stream is closed. Default to true
This commit is contained in:
@@ -40,6 +40,24 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
{
|
||||
private const char Euro = '\u20ac';
|
||||
|
||||
[Test]
|
||||
public void CloseInput()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
BsonReader reader = new BsonReader(ms);
|
||||
|
||||
Assert.IsTrue(ms.CanRead);
|
||||
reader.Close();
|
||||
Assert.IsFalse(ms.CanRead);
|
||||
|
||||
ms = new MemoryStream();
|
||||
reader = new BsonReader(ms) { CloseInput = false };
|
||||
|
||||
Assert.IsTrue(ms.CanRead);
|
||||
reader.Close();
|
||||
Assert.IsTrue(ms.CanRead);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReadSingleObject()
|
||||
{
|
||||
|
||||
@@ -38,6 +38,24 @@ namespace Newtonsoft.Json.Tests.Bson
|
||||
{
|
||||
public class BsonWriterTests : TestFixtureBase
|
||||
{
|
||||
[Test]
|
||||
public void CloseOutput()
|
||||
{
|
||||
MemoryStream ms = new MemoryStream();
|
||||
BsonWriter writer = new BsonWriter(ms);
|
||||
|
||||
Assert.IsTrue(ms.CanRead);
|
||||
writer.Close();
|
||||
Assert.IsFalse(ms.CanRead);
|
||||
|
||||
ms = new MemoryStream();
|
||||
writer = new BsonWriter(ms) { CloseOutput = false };
|
||||
|
||||
Assert.IsTrue(ms.CanRead);
|
||||
writer.Close();
|
||||
Assert.IsTrue(ms.CanRead);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WriteSingleObject()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user