Пример #1
0
        public void ShouldUpdateBlogPost()
        {
            Mock <IAuthorRepository>   authorRepositoryMock   = new Mock <IAuthorRepository>();
            Mock <IBlogPostRepository> blogPostRepositoryMock = new Mock <IBlogPostRepository>();

            authorRepositoryMock.Setup(x => x.GetByUserIdAndId(It.IsAny <string>(), It.IsAny <string>())).Returns(new Author
            {
                Name = "AuthorTest"
            });
            blogPostRepositoryMock.Setup(x => x.GetByUserIdAndId(It.IsAny <string>(), It.IsAny <string>())).Returns(new BlogPost
            {
                Title = "Test"
            });
            var authorData = new BlogPostDTO
            {
                Title    = "Test2",
                AuthorId = "5b9d8e952e6adf8005dbcf21",
                Content  = "test content 2"
            };

            var mapper = TestHelper.GetMapper();
            var sut    = new BlogPostService(authorRepositoryMock.Object, blogPostRepositoryMock.Object, mapper);

            sut.UpdateBlogPost("12345", "5b9d8e952e6adf8005dbcf17", authorData);
        }
Пример #2
0
 public IActionResult Put(int id, [FromBody] BlogPost value)
 {
     if (_blogPostService.UpdateBlogPost(id, value))
     {
         return(Ok());
     }
     else
     {
         return(BadRequest());
     }
 }
Пример #3
0
 public void UpdateBlogPost(BlogPostModel blogPost)
 {
     blogPostService.UpdateBlogPost(blogPost);
 }
        public IActionResult UpdateBlogPost(string id, [FromBody] UserBost updatedBlogPost)
        {
            _blogPostService.UpdateBlogPost(id, updatedBlogPost.Post, updatedBlogPost.Title);

            return(Ok());
        }