コード例 #1
0
        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));
        }
コード例 #2
0
        public PostDto CreatePost(PostRequestModel model)
        {
            var post = postProvider.CreatePost(model);

            return(mapper.Map <PostDto>(post));
        }
コード例 #3
0
        public async Task CreatPost([FromBody] PostCreateValidatable postCreate)
        {
            var post = _mapper.Map <Business.Post.PostCreate>(postCreate);

            await _postProvider.CreatePost(post);
        }