Beispiel #1
0
        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));
        }
Beispiel #2
0
        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);
        }