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."); }
public void IsValidPost_CatchInvalid_Success(string title, string body) { var invalidPost = new Post(title, new Author("authorName", 0), body); Assert.False(_postValidator.IsValidPost(invalidPost)); }