public void Setup() { subscription = new MailingListSubscription { Contact = new Contact() }; var repository = new FakeRepository(id => subscription); var repositoryResolver = MockRepository.GenerateStub<IRepositoryResolver>(); repositoryResolver.Stub(r => r.GetRepository(typeof (MailingListSubscription))).Return(repository); binder = new MailingListSubscriptionBinder(repositoryResolver); valueProvider = new FakeValueProvider(); context = new ModelBindingContext() { ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(MailingListSubscription)), ModelState = new ModelStateDictionary(), ValueProvider = valueProvider }; controllerContext = new ControllerContext { HttpContext = MockRepository.GenerateStub<HttpContextBase>() }; controllerContext.HttpContext.Expect(x => x.Request).Return(MockRepository.GenerateStub<HttpRequestBase>()); controllerContext.HttpContext.Request.Expect(x => x.Form).Return(new NameValueCollection()); }
public void Setup() { validatingBinder = MockRepository.GenerateStub<IValidatingBinder>(); binder = new MailingListSubscriptionBinder(validatingBinder, MockRepository.GenerateStub<IRepositoryResolver>()); binder.Accept(new BindMailingListAttribute()); valueProvider = new FakeValueProvider(); context = new ModelBindingContext() { ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(MailingListSubscription)), ModelState = new ModelStateDictionary(), ValueProvider = valueProvider, ModelName = "subscription", }; controllerContext = new ControllerContext { HttpContext = MockRepository.GenerateStub<HttpContextBase>() }; controllerContext.HttpContext.Expect(x => x.Request).Return(MockRepository.GenerateStub<HttpRequestBase>()); controllerContext.HttpContext.Request.Expect(x => x.Form).Return(new NameValueCollection()); }