public async void GetSchedule_IncorrectGroupId_ThrowsException()
        {
            const int group   = 999999;
            var       date    = new DateTime(2019, 05, 28);
            var       timeout = TimeSpan.FromSeconds(5);
            var       service = new StudentsSchedule(timeout);

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWith("", 404);

                await Assert.ThrowsAsync <FlurlHttpException>(async() => await service.GetLessons(group, date));

                httpTest.ShouldHaveCalled(Constants.EndPoint)
                .WithVerb(HttpMethod.Get)
                .WithQueryParamValue("oid", group)
                .WithQueryParamValue("from", date.ToString("dd.MM.yyyy"))
                .Times(1);
            }
        }
Esempio n. 2
0
        static async Task Main(string[] args)
        {
            var timeout = TimeSpan.FromSeconds(5);

            var teacherSchedule = new TeachersSchedule(timeout);
            var teacherLessons  = await teacherSchedule.GetLessons(22914);

            var studentsSchedule = new StudentsSchedule(timeout);
            var studentsLessons  = await studentsSchedule.GetLessons(9092);

            var schoolsParser = new SchoolsParser(timeout);
            var schools       = await schoolsParser.GetSchools();

            var groupsParser = new GroupsParser(timeout);
            var groups       = await groupsParser.GetGroupsFromSchool(15);

            var teachersParser = new TeachersParser(timeout);
            var teachers       = await teachersParser.GetTeachersInRange(22913, 22917, 3, 1000);

            Console.ReadLine();
        }
        public async void GetSchedule_CorrectGroupId_ReturnsLessons()
        {
            const int group   = 9092;
            var       date    = new DateTime(2019, 05, 28);
            var       timeout = TimeSpan.FromSeconds(5);
            var       service = new StudentsSchedule(timeout);

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWith(File.ReadAllText("TestData/Schedule/students.txt"));

                var result = await service.GetLessons(group, date);

                httpTest.ShouldHaveCalled(Constants.EndPoint)
                .WithVerb(HttpMethod.Get)
                .WithQueryParamValue("oid", group)
                .WithQueryParamValue("from", date.ToString("dd.MM.yyyy"))
                .Times(1);

                Assert.NotEmpty(result);
            }
        }
Esempio n. 4
0
        public async Task GetSchedule_CorrectGroupId_ReturnsLessons()
        {
            const int group            = 9092;
            var       date             = new DateTime(2019, 05, 28);
            var       correctStartDate = new DateTime(2019, 05, 14, 7, 10, 00);
            var       correctEndDate   = new DateTime(2019, 05, 14, 8, 45, 00);

            var timeout = TimeSpan.FromSeconds(5);
            var service = new StudentsSchedule(timeout);

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWith(await File.ReadAllTextAsync("TestData/Schedule/students.txt"));

                var result = await service.GetLessons(group, date);

                var first = result.First();

                httpTest.ShouldHaveCalled(Constants.EndPoint)
                .WithVerb(HttpMethod.Get)
                .WithQueryParamValue("oid", group)
                .WithQueryParamValue("from", date.ToString("dd.MM.yyyy"))
                .Times(1);

                result.Should().NotBeEmpty().And
                .HaveCount(4);
                first.Address.Should().Be("А-НСД2к2");
                first.Auditory.Should().Be("10101");
                first.EndTime.ToUniversalTime().Should().Be(correctEndDate);
                first.Groups.Should().Be("555555");
                first.Name.Should().Be("Предмет2");
                first.Number.Should().Be(2);
                first.StartTime.ToUniversalTime().Should().Be(correctStartDate);
                first.Teacher.Should().Be("Препод2");
                first.Type.Should().Be("Лабораторные занятия");
            }
        }
Esempio n. 5
0
 public ScheduleService(TimeSpan timeout)
 {
     Students = new StudentsSchedule(timeout);
     Teachers = new TeachersSchedule(timeout);
 }