public void RankCannotBeNegative() { // ARRANGE: create a post with minus Rank var post = new HNPost { Rank = -1 }; var validator = new HNPostValidator(HNPage.BASE_URI); // ACT: run the validator on the post validator.ValidatePost(post); // ASSERT: the post should contain a validation error Assert.NotNull(post.ValidationErrors); Assert.True(post.ValidationErrors.Where(e => e.MemberNames.Contains("Rank")).Any()); }
public void UriIsAValidUri() { // ARRANGE: create a post with invalid Uri var post = new HNPost { Uri = "httppp:/notvalid" }; var validator = new HNPostValidator(HNPage.BASE_URI); // ACT: run the validator on the post validator.ValidatePost(post); // ASSERT: the post should contain a validation error Assert.NotNull(post.ValidationErrors); Assert.True(post.ValidationErrors.Where(e => e.MemberNames.Contains("Uri")).Any()); }
public void AuthorCannotBeEmptyString() { // ARRANGE: create a post with empty string author var post = new HNPost { Author = "" }; var validator = new HNPostValidator(HNPage.BASE_URI); // ACT: run the validator on the post validator.ValidatePost(post); // ASSERT: the post should contain a validation error Assert.NotNull(post.ValidationErrors); Assert.True(post.ValidationErrors.Where(e => e.MemberNames.Contains("Author")).Any()); }
public void TitleCannotBeOver256Chars() { // ARRANGE: create a post with Title 257 chars long var post = new HNPost { Title = new string('a', 257) }; var validator = new HNPostValidator(HNPage.BASE_URI); // ACT: run the validator on the post validator.ValidatePost(post); // ASSERT: the post should contain a validation error Assert.NotNull(post.ValidationErrors); Assert.True(post.ValidationErrors.Where(e => e.MemberNames.Contains("Title")).Any()); }