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));
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        public void IsAuthenticatedTest(string page, bool isAuthenticated)
        {
            var parser = new ForumParser(page);

            var actual = parser.IsAuthenticated();

            Assert.AreEqual(isAuthenticated, actual);
        }
Exemple #8
0
        public void GetForumsParser_WhenCalled_ShouldCreateListWithCorrectAmountOfForums()
        {
            List <Forum> forums = ForumParser.GetForumsParser(contentList);

            var listSize = forums.Count;

            Assert.AreEqual(2, listSize);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
 public ForumEndPoint(ForumSettings settings, IHttpClient httpClient)
     : base(settings.CustomHomePageURL, settings.RootURL, httpClient)
 {
     _theme  = settings.Theme;
     _parser = new ForumParser();
 }