public void ContentsClearedBeforeImporting() { JsonArray a = new JsonArray(); a.Add(new object()); Assert.AreEqual(1, a.Length); a.Import(new JsonTextReader(new StringReader("[123]"))); Assert.AreEqual(1, a.Length); }
public void Import() { JsonArray a = new JsonArray(); a.Import(new JsonTextReader(new StringReader("[123,'Hello World',true]"))); Assert.AreEqual(3, a.Length); Assert.AreEqual(123, (int) (JsonNumber) a[0]); Assert.AreEqual("Hello World", a[1]); Assert.AreEqual(true, a[2]); }
public void Import() { JsonArray a = new JsonArray(); a.Import(new JsonTextReader(new StringReader("[123,'Hello World',true]"))); Assert.AreEqual(3, a.Length); Assert.AreEqual(123, (int)(JsonNumber)a[0]); Assert.AreEqual("Hello World", a[1]); Assert.AreEqual(true, a[2]); }
public void ImportIsExceptionSafe() { JsonArray a = new JsonArray(); object o = new object(); a.Add(o); try { a.Import(new JsonTextReader(new StringReader("[123,456,"))); } catch (JsonException) { } Assert.AreEqual(1, a.Count); Assert.AreSame(o, a[0]); }
public void CannotUseNullReaderWithImport() { IJsonImportable array = new JsonArray(); array.Import(new ImportContext(), null); }
public void CannotUseNullContextWithImport() { IJsonImportable array = new JsonArray(); array.Import(null, (new JsonRecorder()).CreatePlayer()); }