public void AddResultsToEncounterOkTest()
        {
            ICollection <EncountersTeams> teams = new List <EncountersTeams>()
            {
                eNacional, ePeñarol
            };
            DateTime            date          = new DateTime(2018, 9, 27, 8, 30, 00);
            PositionInEncounter scoreNacional = new PositionInEncounter()
            {
                TeamId = nacional.Id, Position = 3
            };
            PositionInEncounter scorePeñarol = new PositionInEncounter()
            {
                TeamId = peñarol.Id, Position = 0
            };
            ICollection <PositionInEncounter> results = new List <PositionInEncounter>()
            {
                scoreNacional, scorePeñarol
            };
            ICollection <Encounter> encounterList = new List <Encounter>();
            Encounter encounter = new Encounter()
            {
                Id = 1, Teams = teams, SportId = football.Id, Date = date
            };

            encounterList.Add(encounter);
            mockEncounterRepo.Setup(e => e.Get(It.IsAny <Expression <Func <Encounter, bool> > >(), null, "Teams")).Returns(encounterList);
            encounterBL.Add(encounter);
            encounterBL.AddResults(results, encounter.Id);
            mockEncounterRepo.Verify(x => x.Insert(It.IsAny <Encounter>()), Times.Once());
            mockEncounterRepo.Verify(x => x.Save(), Times.Exactly(2));
            mockEncounterRepo.Verify(x => x.Update(encounter), Times.Once());
        }
Exemple #2
0
        public ActionResult AddResultsToEncounter([FromBody] ResultsDTO results)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                encounterBusinessLogic.AddResults(results.Positions, results.EncounterId);
                return(Ok(new ResponseOkDTO()));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }