public async Task Test_AlreadyImported_ThrowArgumentNullException() { //Arrange _competitionRepository.Setup( x => x.Count(It.IsAny <Expression <Func <Competition, bool> > >())) .ReturnsAsync(1); //Assert await Assert.ThrowsAsync <ArgumentNullException>(async() => await _target.AlreadyImported(null)); await Assert.ThrowsAsync <ArgumentNullException>(async() => await _target.AlreadyImported("")); }
public async Task <IActionResult> Get([Required] string leagueCode) { var exists = await _competitionService.AlreadyImported(leagueCode); if (!exists) { return(NotFound(new Result("Not found"))); } int count = await _competitionService.CountPlayersByCompetition(leagueCode); return(Ok(new PlayerCount(count))); }
public async Task <IActionResult> Get([Required] string leagueCode) { var exists = await _competitionService.AlreadyImported(leagueCode); if (exists) { return(Conflict(new Result("League already imported"))); } Competition competition = await _competitionService.GetCompetition(leagueCode); if (competition == null) { return(NotFound(new Result("Not found"))); } await _competitionService.ImportLeague(competition); return(StatusCode(StatusCodes.Status201Created, new Result("Successfully imported"))); }