public ActionResult DeletePost(int id) { var service = new ShelterService(); service.DeleteShelter(id); TempData["SaveResult"] = "Shelter deleted."; return(RedirectToAction("Index")); }
public async void DeleteShelterFailsForFailedGetShelterResponse() { var shelterRepo = new Mock <IShelterRepository>(); var shelterDogRepo = new Mock <IShelterDogRepository>(); var security = new Mock <ISecurityService>(); var account = new Mock <IAccountService>(); shelterRepo.Setup(r => r.GetShelterApprovalInvariant(It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse <Shelter>() { Successful = false })); var service = new ShelterService(shelterRepo.Object, shelterDogRepo.Object, account.Object, security.Object, mapper, logger); Assert.False((await service.DeleteShelter(-1)).Successful); }
public async void DeleteShelterSuccessfulForSuccessResponses() { var shelterRepo = new Mock <IShelterRepository>(); var shelterDogRepo = new Mock <IShelterDogRepository>(); var security = new Mock <ISecurityService>(); var account = new Mock <IAccountService>(); shelterRepo.Setup(r => r.GetShelterApprovalInvariant(It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse <Shelter>() { Data = new Shelter() })); shelterRepo.Setup(r => r.DeleteShelter(It.IsAny <int>())).Returns(Task.FromResult(new RepositoryResponse())); account.Setup(s => s.DeleteAccount(null, It.IsAny <string>(), null)).Returns(Task.FromResult(new ServiceResponse())); var service = new ShelterService(shelterRepo.Object, shelterDogRepo.Object, account.Object, security.Object, mapper, logger); Assert.True((await service.DeleteShelter(1)).Successful); }