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); } }
internal NntpGroups(IEnumerable <string> groups, bool doParse) { if (groups == null) { this.groups = ImmutableList <string> .Empty; return; } IEnumerable <string> parsedGroups = doParse ? GroupsParser.Parse(groups) : groups; this.groups = parsedGroups.OrderBy(g => g).ToImmutableList(); }
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); } }
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 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); } }
public ParserService(TimeSpan timeout) { Groups = new GroupsParser(timeout); Teachers = new TeachersParser(timeout); Schools = new SchoolsParser(timeout); }
/// <summary> /// Creates a new <see cref="NntpGroups"/> object. /// </summary> public NntpGroups(string groups) : this(GroupsParser.Parse(groups), false) { }
/// <summary> /// Removes values from the <see cref="NntpGroups"/> object. /// </summary> /// <param name="values">One or more NNTP newsgroup names seperated by the ';' character.</param> /// <returns>The <see cref="NntpGroups"/> object so that additional calls can be chained.</returns> public NntpGroupsBuilder Remove(IEnumerable <string> values) { RemoveGroups(GroupsParser.Parse(values)); return(this); }
/// <summary> /// Removes a new value from the <see cref="NntpGroups"/> object. /// </summary> /// <param name="value">One or more NNTP newsgroup names seperated by the ';' character.</param> /// <returns>The <see cref="NntpGroups"/> object so that additional calls can be chained.</returns> public NntpGroupsBuilder Remove(string value) { RemoveGroups(GroupsParser.Parse(value)); return(this); }
/// <summary> /// Adds new values to the <see cref="NntpGroups"/> object. /// </summary> /// <param name="values">One or more NNTP newsgroup names seperated by the ';' character.</param> /// <returns>The <see cref="NntpGroups"/> object so that additional calls can be chained.</returns> public NntpGroupsBuilder Add(IEnumerable <string> values) { AddGroups(GroupsParser.Parse(values)); return(this); }
/// <summary> /// Adds a new value to the <see cref="NntpGroups"/> object. /// </summary> /// <param name="value">One or more NNTP newsgroup names seperated by the ';' character.</param> /// <returns>The <see cref="NntpGroups"/> object so that additional calls can be chained.</returns> public NntpGroupsBuilder Add(string value) { AddGroups(GroupsParser.Parse(value)); return(this); }