public async Task UpdatePostAsyncByManager()
        {
            var post = new PostDto()
            {
                Title        = "Title",
                Author       = "Author",
                CreationDate = DateTime.Now
            };

            await _manager.UpdatePostAsync(post);

            _mockPosts.Verify(m => m.Update(It.IsAny <Post>()), Times.Once);
            _mockUnitOfWork.Verify(m => m.SaveAsync(), Times.Once);
        }
예제 #2
0
        public async Task <IHttpActionResult> Put(int id, [FromBody] PostDto post)
        {
            try
            {
                await _appService.UpdatePostAsync(post);
            }
            catch (DataAccessException ex)
            {
                return(InternalServerError(ex));
            }
            catch (ValidationException ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Content(HttpStatusCode.Accepted, post));
        }