private void AssertPostsMatch(Domain.HackerNews.Post actual, HackerNewsPost expected) { Assert.That(actual.Author, Is.EqualTo(expected.Author)); Assert.That(actual.Comments, Is.EqualTo(expected.Comments)); Assert.That(actual.Points, Is.EqualTo(expected.Points)); Assert.That(actual.Rank, Is.EqualTo(expected.Rank)); Assert.That(actual.Title, Is.EqualTo(expected.Title)); Assert.That(actual.Uri.AbsoluteUri, Is.EqualTo(expected.Href)); }
public bool IsValid(HackerNewsPost post) { return(post != null && IsTitleValid(post.Title) && IsAuthorValid(post.Author) && IsUrlValid(post.Url) && IsCommentValid(post.Comments) && IsRankValid(post.Rank) && IsPointValid(post.Points)); }
public void ShouldReturnFalseIfPostIsNotValid() { var post = new HackerNewsPost { Author = "some one", Comments = 1, Title = "some title", Url = "https://somewhere.tld" }; Assert.False(_hackerNewsPostItemValidator.IsValid(post)); }
public void ShouldReturnTrueIfPostIsValid() { var post = new HackerNewsPost { Author = "some one", Comments = 1, Points = 1, Rank = 1, Title = "some title", Url = "https://somewhere.com" }; Assert.True(_hackerNewsPostItemValidator.IsValid(post)); }
public void SetUp() { _subject = _fixture.Create <HackerNewsPostValidator>(); _post = new HackerNewsPost { Author = "foo", Comments = 1, Href = "http://localhost/bar", Id = "baz", Points = 2, Rank = 3, Title = "qux" }; }
public List <HackerNewsPost> GetHackerNewsPosts(string pageHtml) { var result = new List <HackerNewsPost>(); var sections = GetPostsSectionsFromPage(pageHtml); foreach (var sectionHtml in sections) { var post = new HackerNewsPost { Author = _postSectionParser.GetAuthor(sectionHtml), Title = _postSectionParser.GetTitle(sectionHtml), Url = _postSectionParser.GetUrl(sectionHtml), Comments = _postSectionParser.GetComments(sectionHtml), Points = _postSectionParser.GetPoints(sectionHtml), Rank = _postSectionParser.GetRank(sectionHtml), }; result.Add(post); } return(result); }