public void JsonParserDoesNotEnterInfiniteLoopIfSpecifiedPropertyContainsNoProperties() { var json = Resources.Invalid; var stream = new DummyStreamWriter(json); var jsonParser = new DummyJsonParser(stream.Write(), @"lesson_plan"); jsonParser.Parse(); Assert.AreEqual(10, jsonParser.Result.Count()); }
public void JsonParserExistsGraceFullyIfSpecifiedJsonPropertyNameCannotBeParsed() { var json = Resources.JSON; var stream = new DummyStreamWriter(json); var jsonParser = new DummyJsonParser(stream.Write(), @"incorrect_property"); jsonParser.Parse(); Assert.AreEqual(0, jsonParser.Result.Count()); }
public void JsonParserParsesArrays() { var json = Resources.JSON; var stream = new DummyStreamWriter(json); var jsonParser = new DummyJsonParser(stream.Write(), @"lesson_plan"); jsonParser.Parse(); var lessonPlan = jsonParser.Result.First(); Assert.AreEqual(4, lessonPlan.Levels.Count); }
public void JsonParserParsesSimpleProperties() { var json = Resources.JSON; var stream = new DummyStreamWriter(json); var jsonParser = new DummyJsonParser(stream.Write(), @"lesson_plan"); jsonParser.Parse(); const int expectedDuration = 90; const string expectedtitle = @"Journeys: Lesson 1, Day 1"; var lessonPlan = jsonParser.Result.First(); Assert.AreEqual(expectedDuration, lessonPlan.Duration); Assert.AreEqual(expectedtitle, lessonPlan.Title); }
public void JsonParserParsesSpecifiedJsonPropertyName() { var json = Resources.JSON; var stream = new DummyStreamWriter(json); var jsonParser = new DummyJsonParser(stream.Write(), @"lesson_plan"); jsonParser.Parse(); const int expectedCount = 10; Assert.AreEqual(expectedCount, jsonParser.Result.Count()); const string expectedExternalId = @"JY14E_LP_1.1.1.1"; Assert.AreEqual(expectedExternalId, jsonParser.Result.First().Id); }