Mercurial > altnet-hispano
view Agendas/trunk/src/Agendas.Web.Tests/Controllers/MvcControllerTestsBase.cs @ 264:cef4fc893333
EventoControllerTests: No se estaba pasando el HttpContext al test.
author | juanjose.montesdeocaarbos |
---|---|
date | Sat, 22 Oct 2011 17:27:45 -0300 |
parents | 3339d1da6a63 |
children | 3bb779434ae8 |
line wrap: on
line source
using System.Web; using System.Web.Mvc; using Moq; namespace Agendas.Web.Tests.Controllers { public class MvcControllerTestsBase { protected readonly 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); } } }