public void ReadUnexpectedToken()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.Begin().End();

            reader.ReadToken(JsonTokenClass.Object);
        }
Esempio n. 2
0
        public void SkipArray()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array().String("test").EndArray().End();
            reader.Skip();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 3
0
        public void SetMaxDepth()
        {
            MockedJsonReader reader = new MockedJsonReader();

            Assert.AreNotEqual(42, reader.MaxDepth);
            reader.MaxDepth = 42;
            Assert.AreEqual(42, reader.MaxDepth);
        }
Esempio n. 4
0
        public void ReadUnexpectedToken()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().End();

            reader.ReadToken(JsonTokenClass.Object);
        }
 public void ReadNull()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Null().End();
    
     reader.ReadNull();
     Assert.IsTrue(reader.EOF);
 }
 public void ReadString()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().String("hello").End();
    
     Assert.AreEqual("hello", reader.ReadString());
     Assert.IsTrue(reader.EOF);
 }
Esempio n. 7
0
        public void SkipObject()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Object().Member("foo", "bar").EndObject().End();
            reader.Skip();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 8
0
        public void SkipScalar()
        {
            var reader = new MockedJsonReader();

            reader.Begin().String("test").End();
            reader.Skip();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 9
0
        public void ReadString()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().String("hello").End();

            Assert.AreEqual("hello", reader.ReadString());
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 10
0
        public void ReadNumber()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Number(123456).End();

            Assert.AreEqual("123456", reader.ReadNumber().ToString());
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 11
0
        public void ReadNull()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Null().End();

            reader.ReadNull();
            Assert.IsTrue(reader.EOF);
        }
        public void EOF()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.Begin().End();

            Assert.AreEqual(JsonTokenClass.BOF, reader.TokenClass);
            Assert.IsFalse(reader.Read());
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 13
0
        public void EOF()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().End();

            Assert.AreEqual(JsonTokenClass.BOF, reader.TokenClass);
            Assert.IsFalse(reader.Read());
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 14
0
        public void StepOutOfArrayFromStart()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array().String("one").String("two").String("three").EndArray().End();

            reader.MoveToContent();
            reader.StepOut();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 15
0
        public void SkipArrayElement()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array().String("foo").String("bar").EndArray().End();
            reader.Read();
            reader.Read();
            reader.Skip();
            Assert.AreEqual("bar", reader.ReadString());
        }
Esempio n. 16
0
        public void SkipAdjacentObjects()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array().Object().EndObject().Object().EndObject().EndArray().End();
            reader.ReadToken(JsonTokenClass.Array);
            reader.Skip();
            Assert.AreEqual(JsonTokenClass.Object, reader.TokenClass);
            reader.Skip();
            reader.ReadToken(JsonTokenClass.EndArray);
        }
Esempio n. 17
0
        public void ReadMember()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.Begin().Object().Member("mon", "Monday").EndObject().End();

            reader.ReadToken(JsonTokenClass.Object);
            Assert.AreEqual("mon", reader.ReadMember());
            Assert.AreEqual("Monday", reader.ReadString());
            Assert.AreEqual(JsonTokenClass.EndObject, reader.TokenClass);
            Assert.IsFalse(reader.Read());
        }
Esempio n. 18
0
        public void ReadMember()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Object().Member("mon", "Monday").EndObject().End();

            reader.ReadToken(JsonTokenClass.Object);
            Assert.AreEqual("mon", reader.ReadMember());
            Assert.AreEqual("Monday", reader.ReadString());
            Assert.AreEqual(JsonTokenClass.EndObject, reader.TokenClass);
            Assert.IsFalse(reader.Read());
        }
Esempio n. 19
0
        public void StepOutOfArrayFromMiddle()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array().String("one").String("two").String("three").EndArray().End();

            reader.ReadToken(JsonTokenClass.Array);
            reader.ReadString();
            reader.ReadString();
            reader.StepOut();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 20
0
        public void ReadBoolean()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.Begin().Boolean(true).End();

            Assert.IsTrue(reader.ReadBoolean());
            Assert.IsTrue(reader.EOF);

            reader = new MockedJsonReader();
            reader.Begin().Boolean(false).End();

            Assert.IsFalse(reader.ReadBoolean());
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 21
0
        public void CannotExceedMaxDepth()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.MaxDepth = 2;
            reader.Array().Array().Array();
            reader.Read();
            reader.Read();
            reader.Read();

            // Exception will be thrown here, when attempting to read
            // first value *after* the depth has been exceeded.

            reader.Read();
        }
Esempio n. 22
0
        public void CannotExceedMaxDepth()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.MaxDepth = 2;
            reader.Array().Array().Array();
            reader.Read();
            reader.Read();
            reader.Read();

            // Exception will be thrown here, when attempting to read
            // first value *after* the depth has been exceeded.

            reader.Read();
        }
Esempio n. 23
0
        public void ReadBoolean()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Boolean(true).End();

            Assert.IsTrue(reader.ReadBoolean());
            Assert.IsTrue(reader.EOF);

            reader = new MockedJsonReader();
            reader.Begin().Boolean(false).End();

            Assert.IsFalse(reader.ReadBoolean());
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 24
0
        public void StepOutThroughNestedArray()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array()
            .String("one")
            .String("two").Array()
            .String("three")
            .String("four")
            .EndArray()
            .String("five")
            .EndArray()
            .End();

            reader.MoveToContent();
            reader.StepOut();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 25
0
        public void StepOutFromWithinNestedArray()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array()
            .String("one")
            .String("two").Array()
            .String("three")
            .String("four")
            .EndArray()
            .String("five")
            .EndArray()
            .End();

            reader.ReadToken(JsonTokenClass.Array);
            reader.ReadString();
            reader.ReadString();
            reader.StepOut();
            Assert.AreEqual("five", reader.ReadString());
        }
Esempio n. 26
0
        public void SkipObjectMember()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Object()
            .Member("m1", "v1")
            .Member("m2").Object()
            .Member("m3", "v3")
            .Member("m4", "v4")
            .EndObject()
            .Member("m5", "v5")
            .EndObject()
            .End();
            reader.Read();
            reader.Read();
            reader.Skip();
            Assert.AreEqual(JsonTokenClass.Member, reader.TokenClass);
            Assert.AreEqual("m2", reader.Text);
            reader.Skip();
            Assert.AreEqual("m5", reader.ReadMember());
        }
Esempio n. 27
0
        public void ReadTypedNumber()
        {
            MockedJsonReader reader = new MockedJsonReader();

            reader.Begin().Array().
            Number(123).
            Number(456).
            Number(2.5).
            Number(4.2).
            Number(9.99m).
            EndArray().End();

            reader.ReadToken(JsonTokenClass.Array);
            Assert.AreEqual(123, (int)reader.ReadNumber());
            Assert.AreEqual(456L, (long)reader.ReadNumber());
            Assert.AreEqual(2.5f, (float)reader.ReadNumber());
            Assert.AreEqual(4.2, (double)reader.ReadNumber());
            Assert.AreEqual(9.99m, (decimal)reader.ReadNumber());
            reader.ReadToken(JsonTokenClass.EndArray);
            Assert.IsFalse(reader.Read());
        }
 public void SkipThroughNestedArrays()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array()
         .String("one")
         .String("two").Array()
             .String("three")
             .String("four")
             .EndArray()
         .String("five")
         .EndArray()
     .End();
     
     reader.MoveToContent();
     reader.StepOut();
     Assert.IsTrue(reader.EOF);
 }
 public void SkipFromWithinNestedArray()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array()
         .String("one")
         .String("two").Array()
             .String("three")
             .String("four")
             .EndArray()
         .String("five")
         .EndArray()
     .End();
     
     reader.ReadToken(JsonTokenClass.Array);
     reader.ReadString();
     reader.ReadString();
     reader.StepOut();
     Assert.AreEqual("five", reader.ReadString());
 }
 public void SkipArrayAtEnd()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array().String("one").String("two").String("three").EndArray().End();
     
     reader.ReadToken(JsonTokenClass.Array);
     reader.ReadString();
     reader.ReadString();
     reader.ReadString();
     Assert.AreEqual(JsonTokenClass.EndArray, reader.TokenClass);
     reader.StepOut();
     Assert.IsTrue(reader.EOF);
 }
 public void SkipArrayFromStart()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array().String("one").String("two").String("three").EndArray().End();
     
     reader.MoveToContent();
     reader.StepOut();
     Assert.IsTrue(reader.EOF);
 }
 public void ReadTypedNumber()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array().
         Number(123).
         Number(456).
         Number(2.5).
         Number(4.2).
         Number(9.99m).
     EndArray().End();
    
     reader.ReadToken(JsonTokenClass.Array);
     Assert.AreEqual(123, reader.ReadInt32());
     Assert.AreEqual(456L, reader.ReadInt64());
     Assert.AreEqual(2.5f, reader.ReadSingle());
     Assert.AreEqual(4.2, reader.ReadDouble());
     Assert.AreEqual(9.99m, reader.ReadDecimal());
     Assert.AreEqual(JsonTokenClass.EndArray, reader.TokenClass);
     Assert.IsFalse(reader.Read());
 }
Esempio n. 33
0
        public void ReadTypedNumber()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.Begin().Array().
                Number(123).
                Number(456).
                Number(2.5).
                Number(4.2).
                Number(9.99m).
            EndArray().End();

            reader.ReadToken(JsonTokenClass.Array);
            Assert.AreEqual(123, (int) reader.ReadNumber());
            Assert.AreEqual(456L, (long) reader.ReadNumber());
            Assert.AreEqual(2.5f, (float) reader.ReadNumber());
            Assert.AreEqual(4.2, (double) reader.ReadNumber());
            Assert.AreEqual(9.99m, (decimal) reader.ReadNumber());
            reader.ReadToken(JsonTokenClass.EndArray);
            Assert.IsFalse(reader.Read());
        }
Esempio n. 34
0
        public void DefaultMaxDepth()
        {
            MockedJsonReader reader = new MockedJsonReader();

            Assert.AreEqual(100, reader.MaxDepth);
        }
Esempio n. 35
0
        public void StepOutOfArrayFromMiddle()
        {
            MockedJsonReader reader = new MockedJsonReader();
            reader.Begin().Array().String("one").String("two").String("three").EndArray().End();

            reader.ReadToken(JsonTokenClass.Array);
            reader.ReadString();
            reader.ReadString();
            reader.StepOut();
            Assert.IsTrue(reader.EOF);
        }
Esempio n. 36
0
 public void SkipScalar()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().String("test").End();
     reader.Skip();
     Assert.IsTrue(reader.EOF);
 }
Esempio n. 37
0
 public void SkipObjectMember()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Object()
         .Member("m1", "v1")
         .Member("m2").Object()
             .Member("m3", "v3")
             .Member("m4", "v4")
             .EndObject()
         .Member("m5", "v5")
         .EndObject()
     .End();
     reader.Read();
     reader.Read();
     reader.Skip();
     Assert.AreEqual(JsonTokenClass.Member, reader.TokenClass);
     Assert.AreEqual("m2", reader.Text);
     reader.Skip();
     Assert.AreEqual("m5", reader.ReadMember());
 }
Esempio n. 38
0
 public void SkipObject()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Object().Member("foo", "bar").EndObject().End();
     reader.Skip();
     Assert.IsTrue(reader.EOF);
 }
Esempio n. 39
0
 public void DefaultMaxDepth()
 {
     MockedJsonReader reader = new MockedJsonReader();
     Assert.AreEqual(100, reader.MaxDepth);
 }
Esempio n. 40
0
 public void SkipAdjacentObjects()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array().Object().EndObject().Object().EndObject().EndArray().End();
     reader.ReadToken(JsonTokenClass.Array);
     reader.Skip();
     Assert.AreEqual(JsonTokenClass.Object, reader.TokenClass);
     reader.Skip();
     reader.ReadToken(JsonTokenClass.EndArray);
 }
Esempio n. 41
0
 public void SetMaxDepth()
 {
     MockedJsonReader reader = new MockedJsonReader();
     Assert.AreNotEqual(42, reader.MaxDepth);
     reader.MaxDepth = 42;
     Assert.AreEqual(42, reader.MaxDepth);
 }
 public void ReadNumber()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Number(123456).End();
    
     Assert.AreEqual("123456", reader.ReadNumber());
     Assert.IsTrue(reader.EOF);
 }
Esempio n. 43
0
 public void SkipArrayElement()
 {
     MockedJsonReader reader = new MockedJsonReader();
     reader.Begin().Array().String("foo").String("bar").EndArray().End();
     reader.Read();
     reader.Read();
     reader.Skip();
     Assert.AreEqual("bar", reader.ReadString());
 }