public HttpResponseMessage DeleteContact(int id) { if (id <= 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } try { _contactHandler.Delete(id); } catch (ContactNotFoundException) { return(Request.CreateResponse(HttpStatusCode.NotFound)); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Error while deleting contact")); } return(Request.CreateResponse(HttpStatusCode.OK, "Contact successfully deleted")); }
public void Delete_Should_Call_Repository_To_Delete_Given_Contact() { _contactHandler.Delete(1); _contactRepositoryMock.Verify(x => x.Delete(1), Times.Once()); }