public void Setup() { products= new List<Product>(); images = new List<Image>(); validator = MockRepository.GenerateStub<IValidatingBinder>(); repository = MockRepository.GenerateStub<IRepository<Product>>(); repository.Expect(x => x.GetAll()).Return(products.AsQueryable()); fileService = MockRepository.GenerateStub<IHttpFileService>(); imageOrderableService = MockRepository.GenerateStub<IOrderableService<ProductImage>>(); fileService.Expect(x => x.GetUploadedImages(null)).IgnoreArguments().Return(images); sizeService = MockRepository.GenerateStub<ISizeService>(); var resolver = MockRepository.GenerateStub<IRepositoryResolver>(); controllerContext = new ControllerContext() { HttpContext = MockRepository.GenerateStub<HttpContextBase>() }; controllerContext.HttpContext.Stub(x => x.Request).Return(MockRepository.GenerateStub<HttpRequestBase>()); sizeService.Expect(x => x.WithValues(controllerContext.HttpContext.Request.Form)).Return(sizeService); valueProvider = new FakeValueProvider(); bindingContext = new ModelBindingContext() { ModelState = new ModelStateDictionary(), ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(Product)), ModelName = "product", ValueProvider = valueProvider }; binder = new ProductBinder(validator, resolver, repository, fileService, imageOrderableService, sizeService); }
public ProductBinder(IValidatingBinder validatingBinder, IRepositoryResolver resolver, IRepository<Product> repository, IHttpFileService httpFileService, IOrderableService<ProductImage> orderableService, ISizeService sizeService) : base(validatingBinder, resolver) { this.repository = repository; this.httpFileService = httpFileService; this.orderableService = orderableService; this.sizeService = sizeService; }
public CmsController( IRepository<Content> contentRepository, IOrderableService<Content> contentOrderableService, IValidatingBinder validatingBinder) { this.contentRepository = contentRepository; this.contentOrderableService = contentOrderableService; this.validatingBinder = validatingBinder; }
public void SetUp() { // you have to be an administrator to access the CMS controller Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("admin"), new string[] { "Administrator" }); contentRepository = MockRepository.GenerateStub<IRepository<Content>>(); contentOrderableService = MockRepository.GenerateStub<IOrderableService<Content>>(); validatingBinder = new ValidatingBinder(new SimplePropertyBinder()); cmsController = new CmsController( contentRepository, contentOrderableService, validatingBinder); }
public void SetUp() { // you have to be an administrator to access the CMS controller Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("admin"), new[] { "Administrator" }); postageRepository = MockRepository.GenerateStub<IRepository<Postage>>(); orderableService = MockRepository.GenerateStub<IOrderableService<Postage>>(); validatingBinder = new ValidatingBinder(new SimplePropertyBinder()); httpContextService = MockRepository.GenerateStub<IHttpContextService>(); postageController = new PostageController { Repository = postageRepository, OrderableService = orderableService, ValidatingBinder = validatingBinder, httpContextService = httpContextService }; }
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()); }
public void Setup() { validatingBinder = MockRepository.GenerateStub<IValidatingBinder>(); repository = MockRepository.GenerateStub<IRepository>(); var repositoryResolver = MockRepository.GenerateStub<IRepositoryResolver>(); repositoryResolver.Expect(x => x.GetRepository(typeof(TestEntity))).Return(repository); binder = new DataBinder(validatingBinder, repositoryResolver); context = new ModelBindingContext() { ModelName = "foo", ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(TestEntity)), ModelState = new ModelStateDictionary() }; 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() { { "foo.Id", "3"}, { "foo.Name", "Jeremy" } }).Repeat.Any(); }
public MailingListSubscriptionBinder(IValidatingBinder validatingBinder, IRepositoryResolver resolver) : base(validatingBinder, resolver) { }
public OrderBinder(IValidatingBinder validatingBinder, IEncryptionService encryptionService, IRepository<Basket> basketRepository) { this.validatingBinder = validatingBinder; this.basketRepository = basketRepository; this.encryptionService = encryptionService; }
public DataBinder(IValidatingBinder validatingBinder, IRepositoryResolver resolver) { this.validatingBinder = validatingBinder; this.resolver = resolver; }
public HttpContextService(IValidatingBinder validatingBinder) { this.validatingBinder = validatingBinder; }