public void GetById_NotFound_Test() { // Arrange var mockService = new Mock <IAppointmentTypeService>(); var controller = new AppointmentTypeController(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 <IAppointmentTypeService>(); mockService.Setup(x => x.GetById(id)) .Returns(new AppointmentTypeModel { Id = id }); var controller = new AppointmentTypeController(mockService.Object); // Act IHttpActionResult actionResult = controller.GetById(id); var contentResult = actionResult as OkNegotiatedContentResult <AppointmentTypeModel>; // Assert Assert.IsNotNull(contentResult); Assert.IsNotNull(contentResult.Content); Assert.AreEqual(id, contentResult.Content.Id); }