public void CheckControllerDecoratedWithValidateAntiForgeryToken(string methodName, Type[] parameterType) { var mockImagesService = new Mock <IImagesService>(); var mockCategoryService = new Mock <ICategoriesService>(); UserManager <ApplicationUser> userManager = MockUserManager(); var logger = new Mock <ILogger <ImagesController> >(); ImagesController controller = new ImagesController( mockImagesService.Object, mockCategoryService.Object, userManager, logger.Object); var type = controller.GetType(); var methodInfo = type.GetMethod(methodName, parameterType); var attributes = methodInfo.GetCustomAttributes(typeof(ValidateAntiForgeryTokenAttribute), true); Assert.True(attributes.Any(), $"No ValidateAntiForgeryTokenAttribute found on {methodName} method"); }