public void ReadUnexpectedToken() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().End(); reader.ReadToken(JsonTokenClass.Object); }
public void SkipArray() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().Array().String("test").EndArray().End(); reader.Skip(); Assert.IsTrue(reader.EOF); }
public void SetMaxDepth() { MockedJsonReader reader = new MockedJsonReader(); Assert.AreNotEqual(42, reader.MaxDepth); reader.MaxDepth = 42; Assert.AreEqual(42, reader.MaxDepth); }
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); }
public void SkipObject() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().Object().Member("foo", "bar").EndObject().End(); reader.Skip(); Assert.IsTrue(reader.EOF); }
public void SkipScalar() { var reader = new MockedJsonReader(); reader.Begin().String("test").End(); reader.Skip(); Assert.IsTrue(reader.EOF); }
public void ReadNumber() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().Number(123456).End(); Assert.AreEqual("123456", reader.ReadNumber().ToString()); 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); }
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); }
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 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); }
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 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 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); }
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(); }
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); }
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 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()); }
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()); }
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 DefaultMaxDepth() { MockedJsonReader reader = new MockedJsonReader(); Assert.AreEqual(100, reader.MaxDepth); }
public void SkipScalar() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().String("test").End(); reader.Skip(); Assert.IsTrue(reader.EOF); }
public void ReadNumber() { MockedJsonReader reader = new MockedJsonReader(); reader.Begin().Number(123456).End(); Assert.AreEqual("123456", reader.ReadNumber()); Assert.IsTrue(reader.EOF); }