This commit is contained in:
James Newton-King
2014-05-11 21:58:36 +12:00
parent f8b1936d1f
commit 7a8f5e43bc
2 changed files with 95 additions and 0 deletions
@@ -52,6 +52,30 @@ namespace Newtonsoft.Json.Tests
[TestFixture]
public class JsonTextWriterTest : TestFixtureBase
{
[Test]
public void NewLine()
{
MemoryStream ms = new MemoryStream();
using (var streamWriter = new StreamWriter(ms, new UTF8Encoding(false)) { NewLine = "\n" })
using (var jsonWriter = new JsonTextWriter(streamWriter)
{
CloseOutput = true,
Indentation = 2,
Formatting = Formatting.Indented
})
{
jsonWriter.WriteStartObject();
jsonWriter.WritePropertyName("prop");
jsonWriter.WriteValue(true);
jsonWriter.WriteEndObject();
}
string json = Encoding.UTF8.GetString(ms.ToArray());
Assert.AreEqual(@"{" + '\n' + @" ""prop"": true" + '\n' + "}", json);
}
[Test]
public void QuoteNameAndStrings()
{