public ActionResult Delete(long id) { var service = new ConsultationService(); var consultation = service.GetID(id); if (consultation == null) { return(NotFound()); } service.Delete(consultation); return(Ok()); }
public void DeleteConsultationServiceTest() { //Arrange Consultation Consultation = null; //Fake do repositório var repositoryFake = new Mock <IConsultationRepository>(); repositoryFake.Setup(r => r.Delete(1)).Returns(Consultation); IConsultationService service = new ConsultationService(repositoryFake.Object); //Action var ConsultationFake = service.Delete(1); //Assert repositoryFake.Verify(r => r.Delete(1)); Assert.IsNull(ConsultationFake); }