Ejemplo n.º 1
0
        public Task <GetBoardListCommandResult> GetList(GetBoardListCommand command)
        {
            Task <GetBoardListCommandResult> result;

            result = _mediator.Send(command);

            return(result);
        }
Ejemplo n.º 2
0
        public ActionResult <List <BoardGetOutput> > GetList()
        {
            GetBoardListCommand command = new GetBoardListCommand();

            Task <GetBoardListCommandResult> result      = _boardService.GetList(command);
            List <BoardGetOutput>            returnValue = _mapper.Map <List <GetBoardListCommandResultItem>, List <BoardGetOutput> >(result.Result.ResultObject.Data);

            if (result.Result.ResultObject.Success)
            {
                return(Ok(returnValue));
            }
            else
            {
                return(BadRequest(returnValue));
            }
        }
Ejemplo n.º 3
0
        public async Task GetList_StateUnderTest_ExpectedBehavior()
        {
            BoardService service = new BoardService(mockMediator.Object);
            // Arrange
            // var service = this.CreateService();
            Fixture                   fixture     = new Fixture();
            GetBoardListCommand       command     = fixture.Build <GetBoardListCommand>().With(x => x.BoardId, Guid.NewGuid().ToString()).Create();
            GetBoardListCommandResult resultValue = fixture.Build <GetBoardListCommandResult>().With(x => x.ResultObject, new ServiceResult <List <GetBoardListCommandResultItem> >()
            {
                Success = true
            }).Create();

            this.mockMediator.Setup(m => m.Send(It.IsAny <GetBoardListCommand>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(resultValue);          //<-- return Task to allow await to continue


            // Act
            var result = await service.GetList(
                command);

            // Assert
            Assert.True(true);
            this.mockRepository.VerifyAll();
        }