public async Task GetSchedule_CorrectId_ReturnsLessons() { const int teacherId = 22222; var correctStartDate = new DateTime(2019, 05, 14, 8, 20, 00); var correctEndDate = new DateTime(2019, 05, 14, 9, 55, 00); var timeout = TimeSpan.FromSeconds(5); var service = new TeachersSchedule(timeout); using (var httpTest = new HttpTest()) { httpTest.RespondWith(await File.ReadAllTextAsync("TestData/Schedule/teachers.txt")); var result = await service.GetLessons(teacherId); var first = result.First(); httpTest.ShouldHaveCalled(Constants.EndPoint) .WithVerb(HttpMethod.Get) .WithQueryParamValue("lecturer", teacherId) .Times(1); result.Should().NotBeEmpty().And .HaveCount(48); first.Address.Should().Be("наб. Северной Двины, д. 17"); first.Auditory.Should().Be("ауд. 1255"); first.EndTime.Should().Be(correctEndDate); first.Groups.Should().Be("Группа \"301713\""); first.Name.Should().Be("Физическая химия"); first.Number.Should().Be(1); first.StartTime.Should().Be(correctStartDate); first.Teacher.Should().Be("Богданов Михаил Владиславович. Кафедра теоретической и прикладной химии"); first.Type.Should().Be("Лабораторные занятия"); } }
public async void GetSchedule_IncorrectId_ReturnsLessons() { const int teacherId = 1; var timeout = TimeSpan.FromSeconds(5); var service = new TeachersSchedule(timeout); using (var httpTest = new HttpTest()) { httpTest.RespondWith("", 404); await Assert.ThrowsAsync <FlurlHttpException>(async() => await service.GetLessons(teacherId)); httpTest.ShouldHaveCalled(Constants.EndPoint) .WithVerb(HttpMethod.Get) .WithQueryParamValue("lecturer", teacherId) .Times(1); } }
public async void GetSchedule_CorrectId_ReturnsLessons() { const int teacherId = 22222; var timeout = TimeSpan.FromSeconds(5); var service = new TeachersSchedule(timeout); using (var httpTest = new HttpTest()) { httpTest.RespondWith(File.ReadAllText("TestData/Schedule/teachers.txt")); var result = await service.GetLessons(teacherId); httpTest.ShouldHaveCalled(Constants.EndPoint) .WithVerb(HttpMethod.Get) .WithQueryParamValue("lecturer", teacherId) .Times(1); Assert.NotEmpty(result); } }
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(); }