public void IsValidAuthor_ValidAuthorInList_Success()
        {
            var listOfAuthors = new List <Author>()
            {
                new Author("inRepo", 0)
            };

            _mockAuthorRepo.StubGetListOfAuthors(listOfAuthors);

            Assert.True(_authorValidator.IsValidAuthor(listOfAuthors[0]));
            _mockAuthorRepo.AssertGetListOfAuthorCalled();
        }
Exemple #2
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.");
 }