public void TestPostVote() { Vote a = new Vote() { VoteId = 1, EndDate = DateTime.Now.AddDays(2), YesNoQuestion = "1", Deleted = false, Yes = 2, No = 1 }; var mockVoteValidator = new Mock <IVoteValidator>(); mockVoteValidator.Setup(x => x.PostVote(a)).Verifiable(); mockVoteValidator.Setup(x => x.secure(null)).Verifiable(); mockVoteValidator.Setup(x => x.AtmSecure(null)).Verifiable(); var controller = new VotesController(mockVoteValidator.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.PostVote(a); var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <Vote> >; Assert.IsNotNull(actionResult); }