Example #1
0
        public async Task <IActionResult> GetById(int id)
        {
            // buscar todos ou filtrar

            //var projectComment = _projectCommentService.GetProjectComment(id);
            var command = new GetProjectCommentByIdQuery(id);

            var projectComment = await _mediator.Send(command);

            if (projectComment == null)
            {
                return(NotFound());
            }

            return(Ok(projectComment));
        }
Example #2
0
        public async Task ThreeProjectsExist_Executed_ReturnThreeProjectCommentByIdViewModels()
        {
            // Arrange
            var projectComment = new ProjectComment("Descrição teste", 1, 1);

            var projectCommentRepositoryMock = new Mock <IProjectCommentRepository>();

            projectCommentRepositoryMock.Setup(pc => pc.GetProjectCommentByIdAsync(projectComment.Id).Result).Returns(projectComment);

            var getProjectCommentByIdQuery        = new GetProjectCommentByIdQuery(projectComment.Id);
            var getProjectCommentByIdQueryHandler = new GetProjectCommentByIdQueryHandler(projectCommentRepositoryMock.Object);


            // ACT
            var projectCommentViewModel = await getProjectCommentByIdQueryHandler.Handle(getProjectCommentByIdQuery, new CancellationToken());


            // Assert
            Assert.NotNull(projectCommentViewModel);

            projectCommentRepositoryMock.Verify(pc => pc.GetProjectCommentByIdAsync(projectComment.Id).Result, Times.Once);
        }