public async Task <ActionResult> Delete(int id) { var tournament = await tournamentService.DeleteTournamentByIdAsync(id); if (tournament == null) { return(NotFound()); } else { return(Ok(tournament)); } }
public async Task DeleteTournament_InputIsTournamentData_OneTournamentDeleted(int id) { //Arrange tournamentRepositoryMock.Setup(tournamentRepository => tournamentRepository.DeleteEntityByIdAsync(It.IsAny <int>())) .ReturnsAsync((int id) => { var foundTournament = tournamentsContext.Find(tournament => tournament.Id == id); tournamentsContext.Remove(foundTournament); return(foundTournament); }); int tournamentContextLength = tournamentsContext.Count; //Act var resultTournamentDTO = (await tournamentService.DeleteTournamentByIdAsync(id)) as TournamentDTO; //Assert Assert.IsNotNull(resultTournamentDTO); Assert.AreEqual(tournamentContextLength - 1, tournamentsContext.Count); }