public async Task Should_Create_New_Post() { // Arrange var postCreate = new PostCreate { Content = "Content", Title = "Title", Comments = new[] { new CommentCreate { CommentText = "CommentText" } } }; // Act var post = await _postProvider.CreatePost(postCreate); // Assert var createdPost = _posts.First(); Assert.AreEqual(post.Content, createdPost.Content); Assert.AreEqual(post.Title, createdPost.Title); CollectionAssert.IsNotEmpty(createdPost.Comments); CollectionAssert.AreEqual( post.Comments.Select(x => x.CommentText), createdPost.Comments.Select(x => x.CommentText)); }
public PostDto CreatePost(PostRequestModel model) { var post = postProvider.CreatePost(model); return(mapper.Map <PostDto>(post)); }
public async Task CreatPost([FromBody] PostCreateValidatable postCreate) { var post = _mapper.Map <Business.Post.PostCreate>(postCreate); await _postProvider.CreatePost(post); }