public async void ReturnAllLeaguesWhichExistsInDb()
        {
            IEnumerable <League> leagues = new List <League>
            {
                new League()
                {
                    Id      = 1,
                    Name    = "Primera Division",
                    Country = "Spain",
                    Season  = "2018/2019",
                    MVP     = new Player()
                    {
                        Name = "Lionel", Surname = "Messi"
                    },
                    Winner = new Team()
                    {
                        ShortName = "FC Barcelona"
                    },
                    Rounds = null,
                    Teams  = null
                },
                new League()
                {
                    Id      = 2,
                    Name    = "Serie A",
                    Country = "Italia",
                    Season  = "2017/2018",
                    MVP     = new Player()
                    {
                        Name = "Mauro", Surname = "Icardi"
                    },
                    Winner = new Team()
                    {
                        ShortName = "Juventus"
                    },
                    Rounds = null,
                    Teams  = null
                },
                new League()
                {
                    Id      = 3,
                    Name    = "Lotto Ekstraklasa",
                    Country = "Poland",
                    Season  = "2018/2019",
                    MVP     = new Player()
                    {
                        Name = "Igor", Surname = "Angulo"
                    },
                    Winner = new Team()
                    {
                        ShortName = "Piast Gliwice"
                    },
                    Rounds = null,
                    Teams  = null
                }
            };

            IEnumerable <LeagueDTO> testLeagues = null;

            _repositoryMock.Reset();
            _repositoryMock.Setup(r => r.GetAllAsync()).ReturnsAsync(leagues);

            var expectedLeagues = _mapper.Map <IEnumerable <LeagueDTO> >(leagues);

            // Act
            var err = await Record.ExceptionAsync(async
                                                      () => testLeagues = await _service.GetAllAsync());

            // Arrange
            err.Should().BeNull();

            testLeagues.Should().NotBeNull();

            testLeagues.Should().HaveSameCount(expectedLeagues);

            testLeagues.Should().BeEquivalentTo(expectedLeagues);
        }
Beispiel #2
0
        public async Task <IActionResult> GetAll()
        {
            var result = await _leagueService.GetAllAsync();

            return(result == null || result.Count == 0 ? (IActionResult)NoContent() : Ok(result));
        }
 public async Task <IEnumerable <LeagueDTO> > Handle(GetAllLeaguesQuery request, CancellationToken cancellationToken)
 => await _service.GetAllAsync();