public void GenerateFixtureWithEncountersOnRepoTest() { DateTime date = new DateTime(2018, 10, 1, 12, 00, 00); EncountersTeams etNacional = new EncountersTeams { Team = nacional, TeamId = nacional.Id }; EncountersTeams etPeñarol = new EncountersTeams { Team = peñarol, TeamId = peñarol.Id }; encounterBL.Add(new Encounter { Id = 1, Teams = { etNacional, etPeñarol }, Date = date, SportId = 1 }); ICollection <Encounter> generatedEncounters = roundRobin.GenerateFixture(teamList, date); List <Encounter> encountersToList = generatedEncounters.ToList(); //Sabemos que el primer partido va a ser Nacional Peñarol porque ya esta en el repositorio //entonces la fecha del primer encuentro generado por el algoritmo debe ser un dia mas. Assert.IsTrue(generatedEncounters.ElementAt(0).Date == new DateTime(2018, 10, 2, 12, 00, 00)); }
public ActionResult CreateEncounter([FromBody] EncounterDTO data) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var encounter = mapper.Map <Encounter>(data); encounterBusinessLogic.Add(encounter); return(Ok(mapper.Map <EncounterDTO>(encounter))); } catch (EncounterException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public void AddEncounterOkTest() { ICollection <EncountersTeams> teams = new List <EncountersTeams>() { eNacional, ePeñarol }; var encounter = new Encounter() { Id = 1, Date = DateTime.Now, SportId = football.Id, Teams = teams }; mockEncounterRepo.Setup(x => x.Insert(It.IsAny <Encounter>())).Callback <Encounter>(x => encounterList.Add(encounter)); encounterBL.Add(encounter); mockEncounterRepo.Verify(x => x.Insert(It.IsAny <Encounter>()), Times.Once()); mockEncounterRepo.Verify(x => x.Save(), Times.Once()); }