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); }