public void Delete_Valid_Detail() { DoctorRep loandata = new DoctorRep(db); DoctorsController obj = new DoctorsController(loandata); var data = obj.Delete(1); var okResult = data as OkObjectResult; Assert.AreEqual(200, okResult.StatusCode); }
public void Delete(int?id) { // Arrange DoctorsController controller = new DoctorsController(); // Act ViewResult result = controller.Delete(id) as ViewResult; // Assert Assert.IsNotNull(result); }
public void ShouldCheckResultAfterDeleteFromDoctorsController_WithMock() { var doctor = new Doctor(); var service = new Mock <IDoctorRepository>(); service.Setup(x => x.GetDoctorById(1)).Returns(doctor); _doctorsController = new DoctorsController(service.Object); var expected = doctor; var result = _doctorsController.Delete(1); var actual = ((ViewResult)result).Model as Doctor; Assert.AreEqual(actual, expected); }
public void ShouldCheckResultWhenDoctorIdIsWrongAfterDeleteFromDoctorsController_WithMock() { var doctor = new Doctor(); var service = new Mock <IDoctorRepository>(); service.Setup(x => x.GetDoctorById(1)).Returns(doctor); _doctorsController = new DoctorsController(service.Object); var expectedErrorCode = 404; var result = _doctorsController.Delete(1000000); var viewResult = (HttpNotFoundResult)result; var actual = viewResult.StatusCode; Assert.AreEqual(expectedErrorCode, actual); }