public void Save_TextWriter() { JsonArray array = new JsonArray(new JsonPrimitive(true), null); using (StringWriter writer = new StringWriter()) { array.Save(writer); Assert.Equal("[true, null]", writer.ToString()); } }
public void Save_NullStream_ThrowsArgumentNullException() { JsonArray array = new JsonArray(); Assert.Throws<ArgumentNullException>("stream", () => array.Save((Stream)null)); Assert.Throws<ArgumentNullException>("textWriter", () => array.Save((TextWriter)null)); }
public void Save_Stream() { JsonArray array = new JsonArray(new JsonPrimitive(true), null); using (MemoryStream stream = new MemoryStream()) { array.Save(stream); string result = Encoding.UTF8.GetString(stream.ToArray()); Assert.Equal("[true, null]", result); } }