public void GetReturnsNotFound() { var mockRepository = new Mock <IServiceManager>(); var controller = new ServiceController(mockRepository.Object); Task <IHttpActionResult> actionResult = controller.FindByNameAsync("parameters"); Assert.IsInstanceOfType(actionResult.Result, typeof(NotFoundResult)); }
public void GetReturnsServiceUsingServiceName() { var mockRepository = new Mock <IServiceManager>(); mockRepository.Setup(x => x.FindByNameAsync("treatment")) .Returns(Task.FromResult(new Service { Name = "treatment" })); var controller = new ServiceController(mockRepository.Object); Task <IHttpActionResult> actionResult = controller.FindByNameAsync("treatment"); var contentResult = actionResult.Result as OkNegotiatedContentResult <Service>; Assert.IsNotNull(actionResult.Result); Assert.IsNotNull(contentResult.Content); Assert.IsInstanceOfType(actionResult.Result, typeof(OkNegotiatedContentResult <Service>)); Assert.AreEqual("treatment", contentResult.Content.Name); }