public void Convert_RankNotStrictlyPositive_ThrowsHackerNewsScrapeException(string rankText) { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_ABSOLUTE_URI, VALID_AUTHOR, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, rankText); // Act + Assert Assert.Throws <HackerNewsScrapeException>(() => _contentParser.Convert(rawContent)); }
public void Convert_TitleNullOrWhitespace_ThrowsHackerNewsScrapeException(string titleText) { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, titleText, VALID_ABSOLUTE_URI, VALID_AUTHOR, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, VALID_RANK_TEXT); // Act + Assert Assert.Throws <HackerNewsScrapeException>(() => _contentParser.Convert(rawContent)); }
public void Convert_AuthorTooLong_ThrowsHackerNewsScrapeException() { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_ABSOLUTE_URI, _stringWith257Characters, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, VALID_RANK_TEXT); // Act + Assert Assert.Throws <HackerNewsScrapeException>(() => _contentParser.Convert(rawContent)); }
public void Convert_CommentsNullOrWhiteSpaceOrNegative_ThrowsHackerNewsScrapeException(string commentsText) { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_ABSOLUTE_URI, VALID_AUTHOR, VALID_POINTS_TEXT, commentsText, VALID_RANK_TEXT); // Act + Assert Assert.Throws <HackerNewsScrapeException>(() => _contentParser.Convert(rawContent)); }
public void Convert_UriNullOrWhiteSpace_ThrowsHackerNewsScrapeException(string uri) { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, uri, VALID_AUTHOR, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, VALID_RANK_TEXT); // Act + Assert Assert.Throws <HackerNewsScrapeException>(() => _contentParser.Convert(rawContent)); }
public void Convert_ValidRequest_ReturnsPostWithCorrectAuthor() { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_ABSOLUTE_URI, _stringWith256Characters, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, VALID_RANK_TEXT); // Act var post = _contentParser.Convert(rawContent); // Assert Assert.That(post.Author, Is.EqualTo(_stringWith256Characters)); }
public void Convert_ValidRankText_ReturnsPostWithCorrectRank(string rankText, int expectedRank) { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_ABSOLUTE_URI, VALID_AUTHOR, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, rankText); // Act var parsedPostModel = _contentParser.Convert(rawContent); // Assert Assert.That(parsedPostModel.Rank, Is.EqualTo(expectedRank)); }
public void Convert_ValidCommentsText_ReturnsPostWithCorrectComments(string commentsText, int expectedComments) { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_ABSOLUTE_URI, VALID_AUTHOR, VALID_POINTS_TEXT, commentsText, VALID_RANK_TEXT); // Act var parsedPostModel = _contentParser.Convert(rawContent); // Assert Assert.That(parsedPostModel.Comments, Is.EqualTo(expectedComments)); }
public void Convert_ValidRelativeUri_ReturnsPostWithAbsoluteUri() { // Arrange var rawContent = new ScrapedPostContent( ValidBaseUri, VALID_TITLE, VALID_RELATIVE_URI, VALID_AUTHOR, VALID_POINTS_TEXT, VALID_COMMENTS_TEXT, VALID_RANK_TEXT); // Act var parsedPostModel = _contentParser.Convert(rawContent); // Assert Assert.That(parsedPostModel.Uri, Is.EqualTo(new Uri(ValidBaseUri, VALID_RELATIVE_URI))); }