public void GetMatchesOfSportTest() { teamsRepo.Add(teamA); teamsRepo.Add(teamB); teamsRepo.Add(teamC); serviceToTest.AddEncounter(matchAvsBDto); serviceToTest.AddEncounter(matchBvsCDto); ICollection <EncounterDto> matches = serviceToTest.GetAllEncounterDtos(sport.Name); Assert.AreEqual(matches.Count, 2); }
public IActionResult GetBySport(string sportName) { IActionResult result; try { SetSession(); ICollection <EncounterDto> matches = encounterService.GetAllEncounterDtos(sportName); ICollection <EncounterModelOut> output = matches.Select(m => factory.CreateModelOut(m)).ToList(); result = Ok(output); } catch (ServiceException e) { result = errors.GenerateError(e); } return(result); }
public void GetMatchesOfSportNoDataAccessTest() { sportsRepo.Add(sport); Mock <IEncounterRepository> fakeRepo = new Mock <IEncounterRepository>(); fakeRepo.Setup(r => r.GetAll()).Throws(new DataInaccessibleException()); serviceToTest = new EncounterService(fakeRepo.Object, teamsRepo, sportsRepo, usersRepo, auth.Object); serviceToTest.GetAllEncounterDtos(sport.Name); }