コード例 #1
0
        public async Task GetGroupsFromSchool_CorrectSchoolId_ReturnsGroups()
        {
            const int schoolId = 3;
            var       timeout  = TimeSpan.FromSeconds(5);
            var       service  = new GroupsParser(timeout);

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWith(await File.ReadAllTextAsync("TestData/Parsers/groups.html"));

                var result = await service.GetGroupsFromSchool(schoolId);

                var first = result.First();

                httpTest.ShouldHaveCalled(Constants.EndPoint)
                .WithVerb(HttpMethod.Get)
                .WithQueryParam("groups")
                .WithQueryParamValue("institution", schoolId)
                .Times(1);

                result.Should().NotBeEmpty().And
                .HaveCount(13);
                first.Name.Should()
                .Be("Автоматизация технологических процессов и производств (Автоматизация систем управления производством)");
                first.RealId.Should().Be(351810);
                first.SiteId.Should().Be(9584);
            }
        }
コード例 #2
0
        public async void GetGroupsFromSchool_IncorrectSchoolId_ThrowsException()
        {
            const int schoolId = 9999;
            var       timeout  = TimeSpan.FromSeconds(5);
            var       service  = new GroupsParser(timeout);

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

                await Assert.ThrowsAsync <FlurlHttpException>(async() =>
                                                              await service.GetGroupsFromSchool(schoolId));

                httpTest.ShouldHaveCalled(Constants.EndPoint)
                .WithVerb(HttpMethod.Get)
                .WithQueryParam("groups")
                .WithQueryParamValue("institution", schoolId)
                .Times(1);
            }
        }
コード例 #3
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();
        }
コード例 #4
0
        public async void GetGroupsFromSchool_CorrectSchoolId_ReturnsGroups()
        {
            const int schoolId = 3;
            var       timeout  = TimeSpan.FromSeconds(5);
            var       service  = new GroupsParser(timeout);

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWith(File.ReadAllText("TestData/Parsers/groups.html"));

                var result = await service.GetGroupsFromSchool(schoolId);

                httpTest.ShouldHaveCalled(Constants.EndPoint)
                .WithVerb(HttpMethod.Get)
                .WithQueryParam("groups")
                .WithQueryParamValue("institution", schoolId)
                .Times(1);

                Assert.NotEmpty(result);
            }
        }