public void GetById_NotFound_Test() { // Arrange var mockService = new Mock <IPatientService>(); var controller = new PatientController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetById(-1); // Assert Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); }
public void GetById_Test() { int id = 1; // Arrange var mockService = new Mock <IPatientService>(); mockService.Setup(x => x.GetById(id)) .Returns(new PatientModel { Id = id }); var controller = new PatientController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetById(id); var contentResult = actionResult as OkNegotiatedContentResult <PatientModel>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(id, contentResult.Content.Id); }