private TestController CreateController( ActionContext actionContext, IModelMetadataProvider metadataProvider, Action <MvcOptions> optionsConfigurator ) { var options = actionContext.HttpContext.RequestServices.GetRequiredService <IOptions <MvcOptions> >(); optionsConfigurator.Invoke(options.Value); var controller = new TestController(); controller.ControllerContext = new ControllerContext(actionContext); controller.ObjectValidator = ModelBindingTestHelper.GetObjectValidator(metadataProvider, options); controller.MetadataProvider = metadataProvider; return(controller); }