public override ForumPageMetadata LoadUserBookmarks() { string url = CreateUserBookmarksUri().AbsoluteUri; var doc = new AwfulWebClient().FetchHtml(url).ToHtmlDocument(); return(ForumParser.ParseForumPage(doc)); }
public override ForumPageMetadata LoadForumPage(string forumId, int pageNumber) { string url = CreateForumPageUri(forumId, pageNumber).AbsoluteUri; var doc = new AwfulWebClient().FetchHtml(url).ToHtmlDocument(); return(ForumParser.ParseForumPage(doc)); }
public void PutForumBuilder_AllFieldsChanged() { Forum oldForum = new Forum { Title = theme, Place = place, Schedules = schedules, Date = date, Hour = hour }; Forum newForum = new Forum { Title = newTheme, Place = newPlace, Schedules = newSchedules, Date = newDate, Hour = newHour }; JObject obj = ForumParser.PutForumBuilder(oldForum, newForum); var forumBody = obj["forum"]; var forumTheme = forumBody["theme"].ToString(); var forumPlace = forumBody["place"].ToString(); var forumSchedules = forumBody["schedules"].ToString(); var forumDate = forumBody["date"].ToObject <DateTime>(); int seconds = forumBody["hour"].ToObject <int>(); TimeSpan forumHour = TimeSpan.FromSeconds(seconds); Assert.AreEqual(newTheme, forumTheme); Assert.AreEqual(newPlace, forumPlace); Assert.AreEqual(newSchedules, forumSchedules); Assert.AreEqual(newDate, forumDate); Assert.AreEqual(newHour, forumHour); }
public void PostForumBuilder_WhenCalled_ShouldCreateObjectWithCorrectData() { Forum forum = new Forum { Title = theme, Place = place, Schedules = schedules, Date = date, Hour = hour }; JObject obj = ForumParser.PostForumBuilder(forum); var forumBody = obj["forum"]; var forumTheme = forumBody["theme"].ToString(); var forumPlace = forumBody["place"].ToString(); var forumSchedules = forumBody["schedules"].ToString(); var forumDate = forumBody["date"].ToObject <DateTime>(); int seconds = forumBody["hour"].ToObject <int>(); TimeSpan forumHour = TimeSpan.FromSeconds(seconds); Assert.AreEqual(theme, forumTheme); Assert.AreEqual(place, forumPlace); Assert.AreEqual(schedules, forumSchedules); Assert.AreEqual(date, forumDate); Assert.AreEqual(hour, forumHour); }
public void PutForumBuilder_SomeFieldsChanged() { Forum oldForum = new Forum { Title = theme, Place = place, Schedules = schedules, Date = date, Hour = hour }; Forum newForum = new Forum { Title = newTheme, Hour = newHour, Date = newDate }; JObject obj = ForumParser.PutForumBuilder(oldForum, newForum); var forumBody = obj["forum"]; Debug.WriteLine(forumBody.ToString()); var children = forumBody.Count(); var forumTheme = forumBody["theme"].ToString(); var forumDate = forumBody["date"].ToObject <DateTime>(); int seconds = forumBody["hour"].ToObject <int>(); TimeSpan forumHour = TimeSpan.FromSeconds(seconds); Assert.AreEqual(newTheme, forumTheme); Assert.AreEqual(newDate, forumDate); Assert.AreEqual(newHour, forumHour); Assert.AreEqual(3, children); }
public void PutForumBuilder_OneFieldChanged() { Forum oldForum = new Forum { Title = theme, Place = place, Schedules = schedules, Date = date, Hour = hour }; Forum newForum = new Forum { Title = newTheme, Hour = hour, // using old values to stop autosetting Date = date }; JObject obj = ForumParser.PutForumBuilder(oldForum, newForum); var forumBody = obj["forum"]; Debug.WriteLine(forumBody.ToString()); var children = forumBody.Count(); var forumTheme = forumBody["theme"].ToString(); Assert.AreEqual(newTheme, forumTheme); Assert.AreEqual(1, children); }
public void IsAuthenticatedTest(string page, bool isAuthenticated) { var parser = new ForumParser(page); var actual = parser.IsAuthenticated(); Assert.AreEqual(isAuthenticated, actual); }
public void GetForumsParser_WhenCalled_ShouldCreateListWithCorrectAmountOfForums() { List <Forum> forums = ForumParser.GetForumsParser(contentList); var listSize = forums.Count; Assert.AreEqual(2, listSize); }
public void GetTitlesTest(string page, string json) { var parser = new ForumParser(page); var actual = parser.GetTitles(); var expected = JsonConvert.DeserializeObject <IEnumerable <TopicTitle> >(json); CollectionAssert.AreEquivalent(expected, actual); }
public void GetForumParser_WhenCalled_ShouldCreateForumWithCorrectProperties() { Forum forum = ForumParser.GetForumParser(content, Constants.ForumId); Assert.AreEqual(theme, forum.Title); Assert.AreEqual(place, forum.Place); Assert.AreEqual(schedules, forum.Schedules); Assert.AreEqual(hour, forum.Hour); Assert.AreEqual(date, forum.Date); }
public ForumEndPoint(ForumSettings settings, IHttpClient httpClient) : base(settings.CustomHomePageURL, settings.RootURL, httpClient) { _theme = settings.Theme; _parser = new ForumParser(); }