public ActionResult DeleteHorse(int id)
 {
     try
     {
         _horseService.DeleteHorse(id);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View("Index"));
     }
 }
Example #2
0
        public void DeleteHorse()
        {
            //initiallizing
            var horse           = new Horse();
            var unitOfWork      = new Mock <IUnitOfWork>();
            var finder          = new Mock <IHorseFinder>();
            var horseCollection = new Mock <IRepository <Horse> >();

            var service = new HorseService(unitOfWork.Object, finder.Object, horseCollection.Object);

            //act
            horseCollection.Setup(x => x.Delete(horse))
            .Returns(horse);

            service.DeleteHorse(horse);

            //assert
            horseCollection.Verify(x => x.Delete(It.IsAny <Horse>()), Times.Once);
        }