public void GetEncounterByIdTest() { ICollection <EncountersTeams> teams = new List <EncountersTeams>() { eNacional, ePeñarol }; var encounter = new Encounter() { Id = 1, Date = DateTime.Now, SportId = football.Id, Teams = teams }; encounterList.Add(encounter); mockEncounterRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(encounter); mockEncounterRepo.Setup(e => e.Get(It.IsAny <Expression <Func <Encounter, bool> > >(), null, "Teams")).Returns(encounterList); var encounterFromDb = encounterBL.GetById(It.IsAny <int>()); mockEncounterRepo.Verify(x => x.Get(It.IsAny <Expression <Func <Encounter, bool> > >(), null, "Teams"), Times.Once); }
public ActionResult <EncounterDTO> GetEncounterById(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var encounter = mapper.Map <EncounterDTO>(encounterBusinessLogic.GetById(id)); return(Ok(encounter)); } catch (EncounterDoesNotExistException e) { return(NotFound(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }