예제 #1
0
        public void GetReturnsServiceWithSameId()
        {
            var mockRepository = new Mock <IServiceManager>();

            mockRepository
            .Setup(x => x.FindByIdAsync("testId"))
            .Returns(Task.FromResult(new Service {
                Id = "testId"
            }));

            var controller = new ServiceController(mockRepository.Object);

            Task <IHttpActionResult> actionResult = controller.FindByIdAsync("testId");
            var contentResult = actionResult.Result as OkNegotiatedContentResult <Service>;

            Assert.IsNotNull(actionResult.Result);
            Assert.IsNotNull(contentResult.Content);
            Assert.IsInstanceOfType(actionResult.Result, typeof(OkNegotiatedContentResult <Service>));
            Assert.AreEqual("testId", contentResult.Content.Id);
        }