Beispiel #1
0
        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());
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }