-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:
JamesNK
2011-03-22 05:48:52 +00:00
parent 6f0c382ba7
commit 6a49425267
11 changed files with 122 additions and 3 deletions
@@ -34,6 +34,24 @@ namespace Newtonsoft.Json.Tests
{
public class JsonTextWriterTest : TestFixtureBase
{
[Test]
public void CloseOutput()
{
MemoryStream ms = new MemoryStream();
JsonTextWriter writer = new JsonTextWriter(new StreamWriter(ms));
Assert.IsTrue(ms.CanRead);
writer.Close();
Assert.IsFalse(ms.CanRead);
ms = new MemoryStream();
writer = new JsonTextWriter(new StreamWriter(ms)) { CloseOutput = false };
Assert.IsTrue(ms.CanRead);
writer.Close();
Assert.IsTrue(ms.CanRead);
}
[Test]
public void ValueFormatting()
{