예제 #1
0
파일: User.cs 프로젝트: toranb/TwitterClone
        public virtual void AddPost(Post post)
        {
            if (post == null) return;

            if (!post.HasValidLength()) return;

            post.PostedBy = this;
            posts.Add(post);
        }
예제 #2
0
        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));
        }
예제 #3
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."));
        }