public virtual void AddPost(Post post) { if (post == null) return; if (!post.HasValidLength()) return; post.PostedBy = this; posts.Add(post); }
public void PostWillAllowForBodyWithLessThan140Characters() { var body = "doh!"; var post = new Post { Body = body }; var valid = post.HasValidLength(); Assert.That(valid, Is.True); Assert.That(post.Errors.ToList().Count, Is.EqualTo(0)); }
public void PostWillNotAllowForBodyWithGreaterThan140Characters() { var body = "doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh! doh!"; var post = new Post { Body = body }; var valid = post.HasValidLength(); Assert.That(valid, Is.False); Assert.That(post.Errors.ToList().Count, Is.EqualTo(1)); Assert.That(post.Errors, Has.Member("Body must be 140 characters or less.")); }