public new void SetUp() { _serviceProvider = new TestServiceProvider(); _store = new Store { Id = 1 }; _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(_store); _categoryService = new Mock <ICategoryService>(); _manufacturerService = new Mock <IManufacturerService>(); _productService = TestProductService.Init(); _productAttributeParser = new Mock <IProductAttributeParser>(); _shoppingCartSettings = new ShoppingCartSettings(); _catalogSettings = new CatalogSettings(); _cacheManager = new MemoryCacheManager(new Mock <IMemoryCache>().Object); _workContext = new Mock <IWorkContext>(); _discountService = TestDiscountService.Init(); _priceCalcService = new PriceCalculationService(_catalogSettings, new CurrencySettings { PrimaryStoreCurrencyId = 1 }, _categoryService.Object, _serviceProvider.CurrencyService.Object, _discountService, _manufacturerService.Object, _productAttributeParser.Object, _productService, _cacheManager, _storeContext.Object, _workContext.Object, _shoppingCartSettings); var nopEngine = new Mock <NopEngine>(); nopEngine.Setup(x => x.ServiceProvider).Returns(_serviceProvider); EngineContext.Replace(nopEngine.Object); }
public new void SetUp() { _serviceProvider = new TestServiceProvider(); _store = new Store { Id = 1 }; _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(_store); _categoryService = new Mock <ICategoryService>(); _customerRoleRepository = new Mock <IRepository <CustomerRole> >(); _customerRoleRepository.Setup(r => r.Table).Returns(GetMockCustomerRoles); _customerCustomerRoleMappingRepository = new Mock <IRepository <CustomerCustomerRoleMapping> >(); var customerCustomerRoleMapping = new List <CustomerCustomerRoleMapping>(); _customerCustomerRoleMappingRepository.Setup(r => r.Table) .Returns(customerCustomerRoleMapping.AsQueryable()); _customerCustomerRoleMappingRepository.Setup(r => r.Insert(It.IsAny <CustomerCustomerRoleMapping>())) .Callback( (CustomerCustomerRoleMapping ccrm) => { customerCustomerRoleMapping.Add(ccrm); }); _customerService = new CustomerService(new CachingSettings(), null, new FakeCacheKeyService(), null, null, null, null, null, _customerCustomerRoleMappingRepository.Object, null, _customerRoleRepository.Object, null, null, new TestCacheManager(), _storeContext.Object, null); _manufacturerService = new Mock <IManufacturerService>(); _productRepository = new Mock <IRepository <Product> >(); _productRepository.Setup(p => p.Table).Returns(GetMockProducts); _productRepository.Setup(p => p.GetById(It.IsAny <int>())) .Returns((int id) => GetMockProducts().FirstOrDefault(p => p.Id == id)); _tierPriceRepository = new Mock <IRepository <TierPrice> >(); _tierPriceRepository.Setup(t => t.Table).Returns(GetMockTierPrices); _discountProductMappingRepository = new Mock <IRepository <DiscountProductMapping> >(); _discountProductMappingRepository.Setup(r => r.Table).Returns(GetMockDiscountProductMapping); _serviceProvider.DiscountProductMappingRepository.Setup(r => r.Table) .Returns(GetMockDiscountProductMapping); var shipmentRepository = new Mock <IRepository <Shipment> >(); _productService = new ProductService(new CatalogSettings(), new CommonSettings(), null, new FakeCacheKeyService(), _customerService, null, null, null, null, null, null, null, null, null, _discountProductMappingRepository.Object, _productRepository.Object, null, null, null, null, null, null, null, null, shipmentRepository.Object, null, null, _tierPriceRepository.Object, null, null, null, null, null, new LocalizationSettings()); _productAttributeParser = new Mock <IProductAttributeParser>(); _catalogSettings = new CatalogSettings(); _staticCacheManager = new TestCacheManager(); _workContext = new Mock <IWorkContext>(); _discountService = TestDiscountService.Init( new List <Discount> { _mockDiscount }.AsQueryable(), new List <DiscountProductMapping> { new DiscountProductMapping { DiscountId = 1, EntityId = 1 } }.AsQueryable()); _priceCalcService = new PriceCalculationService(_catalogSettings, new CurrencySettings { PrimaryStoreCurrencyId = 1 }, new FakeCacheKeyService(), _categoryService.Object, _serviceProvider.CurrencyService.Object, _customerService, _discountService, _manufacturerService.Object, _productAttributeParser.Object, _productService, _staticCacheManager, _storeContext.Object, _workContext.Object); var nopEngine = new Mock <NopEngine>(); nopEngine.Setup(x => x.ServiceProvider).Returns(_serviceProvider); EngineContext.Replace(nopEngine.Object); }
public new void SetUp() { base.SetUp(); _serviceProvider = new TestServiceProvider(); _store = new Store { Id = 1 }; _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(_store); _categoryService = new Mock <ICategoryService>(); _customerRoleRepository = new FakeRepository <CustomerRole>(GetMockCustomerRoles().ToList()); var customerCustomerRoleMapping = new List <CustomerCustomerRoleMapping>(); _customerCustomerRoleMappingRepository = new FakeRepository <CustomerCustomerRoleMapping>(customerCustomerRoleMapping); _customerService = new CustomerService(null, null, null, null, null, _customerCustomerRoleMappingRepository, null, _customerRoleRepository, null, null, new TestCacheManager(), _storeContext.Object, null); _manufacturerService = new Mock <IManufacturerService>(); _productRepository = new FakeRepository <Product>(GetMockProducts().ToList()); _tierPriceRepository = new FakeRepository <TierPrice>(GetMockTierPrices().ToList()); _discountProductMappingRepository = new FakeRepository <DiscountProductMapping>(GetMockDiscountProductMapping().ToList()); _serviceProvider.DiscountProductMappingRepository.Insert(GetMockDiscountProductMapping().First()); var shipmentRepository = new FakeRepository <Shipment>(); _productService = new ProductService(new CatalogSettings(), new CommonSettings(), null, _customerService, null, null, null, null, null, null, null, null, _discountProductMappingRepository, _productRepository, null, null, null, null, null, null, null, null, shipmentRepository, null, null, _tierPriceRepository, null, new TestCacheManager(), null, null, null, new LocalizationSettings()); _productAttributeParser = new Mock <IProductAttributeParser>(); _catalogSettings = new CatalogSettings(); _staticCacheManager = new TestCacheManager(); _workContext = new Mock <IWorkContext>(); _discountService = TestDiscountService.Init( new List <Discount> { _mockDiscount }.AsQueryable(), new List <DiscountProductMapping> { new DiscountProductMapping { DiscountId = 1, EntityId = 1 } }.AsQueryable()); _priceCalcService = new PriceCalculationService(_catalogSettings, new CurrencySettings { PrimaryStoreCurrencyId = 1 }, _categoryService.Object, _serviceProvider.CurrencyService.Object, _customerService, _discountService, _manufacturerService.Object, _productAttributeParser.Object, _productService, _staticCacheManager, _storeContext.Object, _workContext.Object); var nopEngine = new Mock <NopEngine>(); nopEngine.Setup(x => x.ServiceProvider).Returns(_serviceProvider); EngineContext.Replace(nopEngine.Object); }