예제 #1
0
 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);
 }
예제 #2
0
        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);
        }
예제 #3
0
 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]);
 }
예제 #4
0
        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]);
        }
예제 #5
0
        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]);
        }
예제 #6
0
 public void CannotUseNullReaderWithImport()
 {
     IJsonImportable array = new JsonArray();
     array.Import(new ImportContext(), null);
 }
예제 #7
0
 public void CannotUseNullContextWithImport()
 {
     IJsonImportable array = new JsonArray();
     array.Import(null, (new JsonRecorder()).CreatePlayer());
 }
예제 #8
0
        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]);
        }
예제 #9
0
        public void CannotUseNullContextWithImport()
        {
            IJsonImportable array = new JsonArray();

            array.Import(null, (new JsonRecorder()).CreatePlayer());
        }
예제 #10
0
        public void CannotUseNullReaderWithImport()
        {
            IJsonImportable array = new JsonArray();

            array.Import(new ImportContext(), null);
        }