Beispiel #1
0
        public void GettingLessonsIntegrationTest()
        {
            var provider = new PlanProvider(TestPlanUrl);

            var lessonForClass = LessonParser.GetLessonsForClass(provider, "24")
                                 .Where(l => l.DayOfWeek == 1 && l.Number == 6).First();
            var lessonForTeacher = LessonParser.GetLessonsForTeacher(provider, "14")
                                   .Where(l => l.DayOfWeek == 1 && l.Number == 6).First();
            var lessonForRoom = LessonParser.GetLessonsForRoom(provider, "41")
                                .Where(l => l.DayOfWeek == 1 && l.Number == 6).First();

            Assert.Equal(lessonForClass, lessonForTeacher);
            Assert.Equal(lessonForClass, lessonForRoom);
            Assert.Equal(lessonForTeacher, lessonForRoom);
        }
Beispiel #2
0
        public void GettingLessonsForClass()
        {
            var provider = new PlanProvider(TestPlanUrl);

            var expectedLesson = new Lesson()
            {
                Number = 3,
                Period = new Period()
                {
                    Start = "09:50:00", End = "10:35:00"
                },
                DayOfWeek = 1,
                Name      = "zaj. wych.",
                ClassId   = "24",
                TeacherId = "13",
                RoomId    = "49"
            };

            var actualLesson = LessonParser.GetLessonsForClass(provider, "24")
                               .Where(l => l.DayOfWeek == 1 && l.Number == 3).First();

            Assert.Equal(expectedLesson, actualLesson);
        }
 public ActionResult ForClass([FromQuery][Required] string planUrl, [FromQuery][Required] string classId)
 {
     if (String.IsNullOrWhiteSpace(planUrl) || String.IsNullOrWhiteSpace(classId))
     {
         return(BadRequest());
     }
     else
     {
         try
         {
             var provider = new PlanProvider(planUrl);
             return(Ok(LessonParser.GetLessonsForClass(provider, classId)));
         }
         catch (WebException e)
         {
             return(StatusCode(406, $"Error during plan download: '{e.Message}'"));
         }
         catch (UriFormatException e)
         {
             return(StatusCode(406, $"Error during parsing url: '{e.Message}'"));
         }
     }
 }