Exemplo n.º 1
0
 public Post AddPost(Post post)
 {
     if (_postValidator.IsValidPost(post) && _authorValidator.IsValidAuthor(post.Author))
     {
         post.PostID    = Guid.NewGuid();
         post.Timestamp = DateTime.UtcNow;
         var isSuccessful = _postRepo.TryAddPost(post, out var result);
         return((isSuccessful) ? result : throw new ArgumentException("Something went horribly wrong in PostDataAccess.AddPost."));
     }
     throw new ArgumentException("This post has invaild properties.");
 }
Exemplo n.º 2
0
        public void IsValidPost_CatchInvalid_Success(string title, string body)
        {
            var invalidPost = new Post(title, new Author("authorName", 0), body);

            Assert.False(_postValidator.IsValidPost(invalidPost));
        }