Ejemplo n.º 1
0
        public async Task <ActionResult <ListTeamsResponse> > ListTeams(CancellationToken cancellationToken)
        {
            var response = new ListTeamsResponse();
            var dbList   = await _teamsRepository.ListAsync(cancellationToken);

            response.Teams.AddRange(_mapper.Map <IReadOnlyList <TeamDto> >(dbList));
            return(Ok(response));
        }
        public void GetTeamsReturns200AndEmptyListWhenNoTeamsFound()
        {
            var request   = TestHelpers.CreateGetTeamsRequest();
            var teamsList = new ListTeamsResponse()
            {
                Teams = new List <TeamResponse>()
            };

            _teamsUseCase.Setup(x => x.ExecuteGet(request)).Returns(teamsList);
            var response = _teamController.GetTeams(request) as ObjectResult;

            response?.StatusCode.Should().Be(200);
            ((ListTeamsResponse)response?.Value)?.Teams.Should().BeEmpty();
        }
        public void GetTeamsReturns200AndTeamsWhenSuccessful()
        {
            var request   = TestHelpers.CreateGetTeamsRequest();
            var teamsList = new ListTeamsResponse()
            {
                Teams = new List <TeamResponse> {
                    TestHelpers.CreateTeam().ToDomain().ToResponse()
                }
            };

            _teamsUseCase.Setup(x => x.ExecuteGet(request)).Returns(teamsList);
            var response = _teamController.GetTeams(request) as ObjectResult;

            response?.StatusCode.Should().Be(200);
            response?.Value.Should().BeEquivalentTo(teamsList);
        }