public void GetAllEncountersOfSportTest()
        {
            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);
            int sportId = 1;

            encounterBL.GetAllEncountersOfSport(sportId);
            mockEncounterRepo.Verify(x => x.Get(It.IsAny <Expression <Func <Encounter, bool> > >(), null, It.IsAny <string>()), Times.Once());
        }
Example #2
0
        public ActionResult <ICollection <EncounterDTO> > GetAllEncountersOfSport(int sportId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var encounters = mapper.Map <EncounterDTO[]>(encounterBusinessLogic.GetAllEncountersOfSport(sportId));
                return(Ok(encounters));
            }
            catch (NoEncountersFoundForSportException e)
            {
                return(NotFound(e.Message));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }