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); }
public void ReadString() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().String("hello").End(); Assert.AreEqual("hello", reader.ReadString()); Assert.IsTrue(reader.EOF); }
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()); }
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()); }
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()); }
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); }