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