public void DeleteEncounterOkTest()
        {
            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(x => x.Insert(It.IsAny <Encounter>())).Callback <Encounter>(x => encounterList.Add(encounter));
            mockEncounterRepo.Setup(x => x.Delete(It.IsAny <Encounter>())).Callback <Encounter>(x => encounterList.RemoveAt(0));
            mockEncounterRepo.Setup(e => e.Get(It.IsAny <Expression <Func <Encounter, bool> > >(), null, "Teams")).Returns(encounterList);
            encounterBL.Add(encounter);
            encounterBL.Delete(encounter.Id);
            mockEncounterRepo.Verify(x => x.Insert(It.IsAny <Encounter>()), Times.Once());
            mockEncounterRepo.Verify(x => x.Delete(It.IsAny <int>()), Times.Once());
            mockEncounterRepo.Verify(x => x.Save(), Times.AtLeast(2));
        }
Example #2
0
        public ActionResult DeleteEncounter(int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                encounterBusinessLogic.Delete(id);
                return(Ok(new ResponseOkDTO()));
            }
            catch (EncounterDoesNotExistException e)
            {
                return(NotFound(e.Message));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }