private static ModelBinderFactory GetModelBinderFactory(IModelBinder binder)
        {
            var provider = new Mock <IModelBinderProvider>();

            provider
            .Setup(p => p.GetBinder(It.IsAny <ModelBinderProviderContext>()))
            .Returns(binder);

            return(TestModelBinderFactory.Create(provider.Object));
        }
Ejemplo n.º 2
0
        private static IModelBinder CreateBinder(DefaultModelBindingContext bindingContext)
        {
            var factory  = TestModelBinderFactory.Create(bindingContext.HttpContext.RequestServices);
            var metadata = bindingContext.ModelMetadata;

            return(factory.CreateBinder(new ModelBinderFactoryContext()
            {
                Metadata = metadata,
                BindingInfo = new BindingInfo()
                {
                    BinderModelName = metadata.BinderModelName,
                    BinderType = metadata.BinderType,
                    BindingSource = metadata.BindingSource,
                    PropertyFilterProvider = metadata.PropertyFilterProvider,
                },
            }));
        }