public void Delete_ShouldDeleteSuccessfully() { DeleteLostPetBM bm = new DeleteLostPetBM() { Id = 1 }; this._controller.ConfirmDelete(bm); Assert.AreEqual(null, this._context.LostPets.FirstOrDefault(pet => pet.Id == 1)); }
public ActionResult ConfirmDelete(DeleteLostPetBM bind) { string username = User.Identity.Name; if (ModelState.IsValid && this.service.PetBelongsToUser(username, bind.Id) || User.IsInRole("Admin")) { this.service.DeleteLostPet(bind.Id); return(RedirectToAction("profile", "users")); } return(RedirectToAction("index", "home")); }