public void CheckVoteControllerDecoratedWithValidateAntiForgeryToken() { UserManager <ApplicationUser> userManager = MockUserManager(); var mockVoteService = new Mock <IVotesService>(); var mockImageService = new Mock <IImagesService>(); VotesController controller = new VotesController( userManager, mockVoteService.Object, mockImageService.Object).WithIdentity(FirstTestUserId, "TestUser"); var type = controller.GetType(); var methodInfo = type.GetMethod("Index", new Type[] { typeof(VoteInputModel) }); var attributes = methodInfo.GetCustomAttributes(typeof(ValidateAntiForgeryTokenAttribute), true); Assert.True(attributes.Any(), "No ValidateAntiForgeryTokenAttribute found on Index method"); }