Mercurial > altnet-hispano
annotate Agendas/trunk/src/Agendas.Web.Tests/Controllers/MvcControllerTestsBase.cs @ 302:11dddcc9a862 tip
Historico de Eventos, no muestra bien la Url del Patrocinador.
author | juanjose.montesdeocaarbos |
---|---|
date | Tue, 14 Aug 2012 21:54:30 -0300 |
parents | bf993f99cee3 |
children |
rev | line source |
---|---|
262 | 1 using System.Web; |
2 using System.Web.Mvc; | |
275
bf993f99cee3
Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
270
diff
changeset
|
3 using System.Web.Routing; |
262 | 4 using Moq; |
5 | |
6 namespace Agendas.Web.Tests.Controllers | |
7 { | |
8 public class MvcControllerTestsBase | |
9 { | |
275
bf993f99cee3
Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
270
diff
changeset
|
10 protected ControllerContext ControllerCtx = new ControllerContext(); |
262 | 11 |
12 protected static TModel BindModel<TModel>(Controller controller, IValueProvider valueProvider) where TModel : class | |
13 { | |
14 var binder = ModelBinders.Binders.GetBinder(typeof(TModel)); | |
15 var bindingContext = new ModelBindingContext() | |
16 { | |
17 FallbackToEmptyPrefix = true, | |
18 ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(TModel)), | |
19 ModelName = "NotUsedButNotNull", | |
20 ModelState = controller.ModelState, | |
21 PropertyFilter = (name => true), | |
22 ValueProvider = valueProvider | |
23 }; | |
24 | |
275
bf993f99cee3
Ticket #123: Patrocinadores de las vans.
juanjose.montesdeocaarbos
parents:
270
diff
changeset
|
25 return (TModel)binder.BindModel(controller.ControllerContext, bindingContext); |
262 | 26 } |
27 } | |
28 } |