public void DeleteSportOkTest() { Sport sport = new Sport() { Id = 1, Name = "Futbol" }; mockSportRepo.Setup(r => r.GetById(It.IsAny <int>())).Returns(sport); mockSportRepo.Setup(x => x.Delete(It.IsAny <int>())).Callback <object>(x => sportList.Clear()); sportBL.Delete(sport.Id); mockSportRepo.Verify(x => x.Delete(It.IsAny <int>()), Times.Once()); mockSportRepo.Verify(x => x.Save(), Times.AtLeastOnce()); }
public ActionResult DeleteSport(int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { sportBusinessLogic.Delete(id); return(Ok(new ResponseOkDTO())); } catch (SportDoesNotExistException e) { return(NotFound(e.Message)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }