Beispiel #1
0
        public async Task ReturnLeagueWhichExistsInDbByGivenId()
        {
            // Arrange
            _leagueRepository = SoccerStatisticsContextMocker.GetInMemoryLeagueRepository("GetLeagueByIdReturnLeague");

            var expectedLeague = new League()
            {
                Id      = 1,
                Name    = "Primera Division",
                Country = "Spain",
                Season  = "2018/2019",
                MVP     = new Player()
                {
                    Id = 1, Name = "Lionel", Surname = "Messi"
                },
                Winner = new Team()
                {
                    Id = 1, ShortName = "FC Barcelona"
                }
            };

            League testLeague = null;

            // Act
            var err = await Record.ExceptionAsync(async
                                                      () => testLeague = await _leagueRepository.GetByIdAsync(1));

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

            testLeague.Should().NotBeNull();

            testLeague.Should().BeEquivalentTo(expectedLeague);
        }
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var league = await _leagueRepository.GetByIdAsync(id.Value);

            if (league == null)
            {
                Response.StatusCode = 404;
                return(View("LeagueNotFound", id.Value));
            }

            return(View(league));
        }
Beispiel #3
0
        public async Task ReturnNullWhenLeagueDoNotExistsInDbByGivenId()
        {
            // Arrange
            _leagueRepository = SoccerStatisticsContextMocker.GetInMemoryLeagueRepository("GetLeagueByIdReturnNull");

            League testLeague = null;

            // Act
            var err = await Record.ExceptionAsync(async
                                                      () => testLeague = await _leagueRepository.GetByIdAsync(0));

            // Assert
            err.Should().BeNull();
            testLeague.Should().BeNull();
        }
        public async Task <LeagueDTO> GetByIdAsync(uint id)
        {
            var league = await _leagueRepository.GetByIdAsync(id);

            return(_mapper.Map <LeagueDTO>(league));
        }