public void TestPostService() { Service a = new Service() { ServiceId = "1", Name = "Service1", Building = "1" }; var mockServiceValidator = new Mock <IServiceValidator>(); mockServiceValidator.Setup(x => x.PostService(a)).Verifiable(); mockServiceValidator.Setup(x => x.secure(null)).Verifiable(); mockServiceValidator.Setup(x => x.AtmSecure(null)).Verifiable(); var controller = new ServicesController(mockServiceValidator.Object); var controllerContext = new HttpControllerContext(); var request = new HttpRequestMessage(); request.Headers.Add("TODO_PAGOS_TOKEN", "1"); controllerContext.Request = request; controller.ControllerContext = controllerContext; IHttpActionResult actionResult = controller.PostService(a); var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <Service> >; Assert.IsNotNull(actionResult); }