-Tests
This commit is contained in:
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user