view Agendas/trunk/src/Agendas.Web.Tests/Controllers/MvcControllerTestsBase.cs @ 298:9bc60d166c8a

Se corrigieron los tests por el cambio de Patrocinador, para que no persista el logo en disco. Se comentó el código de PatrocinadorApiController, que no se utiliza.
author juanjose.montesdeocaarbos
date Sun, 19 Feb 2012 16:00:38 -0300
parents bf993f99cee3
children
line wrap: on
line source

using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Moq;

namespace Agendas.Web.Tests.Controllers
{
    public class MvcControllerTestsBase
    {
    	protected ControllerContext ControllerCtx = new ControllerContext();

        protected static TModel BindModel<TModel>(Controller controller, IValueProvider valueProvider) where TModel : class
        {
            var binder = ModelBinders.Binders.GetBinder(typeof(TModel));
            var bindingContext = new ModelBindingContext()
            {
                FallbackToEmptyPrefix = true,
                ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(TModel)),
                ModelName = "NotUsedButNotNull",
                ModelState = controller.ModelState,
                PropertyFilter = (name => true),
                ValueProvider = valueProvider
            };

			return (TModel)binder.BindModel(controller.ControllerContext, bindingContext);
        }
    }
}