public static IDiscountService Init(IQueryable <Discount> discounts = default, IQueryable <DiscountProductMapping> productDiscountMapping = null) { var staticCacheManager = new TestCacheManager(); var discountRepo = new Mock <IRepository <Discount> >(); discountRepo.Setup(r => r.Table).Returns(discounts); var discountRequirementRepo = new Mock <IRepository <DiscountRequirement> >(); discountRequirementRepo.Setup(x => x.Table).Returns(new List <DiscountRequirement>().AsQueryable()); var discountUsageHistoryRepo = new Mock <IRepository <DiscountUsageHistory> >(); var discountMappingRepo = new Mock <IRepository <DiscountMapping> >(); discountMappingRepo.Setup(x => x.Table).Returns(productDiscountMapping); var customerService = new Mock <ICustomerService>(); var localizationService = new Mock <ILocalizationService>(); var productService = new Mock <IProductService>(); var eventPublisher = new Mock <IEventPublisher>(); var pluginService = new FakePluginService(); var discountPluginManager = new DiscountPluginManager(customerService.Object, pluginService); var store = new Store { Id = 1 }; var storeContext = new Mock <IStoreContext>(); storeContext.Setup(x => x.CurrentStore).Returns(store); var orderRepo = new Mock <IRepository <Order> >(); var discountService = new TestDiscountService( new FakeCacheKeyService(), customerService.Object, discountPluginManager, eventPublisher.Object, localizationService.Object, productService.Object, discountRepo.Object, discountRequirementRepo.Object, discountUsageHistoryRepo.Object, orderRepo.Object, staticCacheManager, storeContext.Object); return(discountService); }
public static IDiscountService Init() { var cacheManager = new TestCacheManager(); var discountRepo = new Mock <IRepository <Discount> >(); var discountRequirementRepo = new Mock <IRepository <DiscountRequirement> >(); discountRequirementRepo.Setup(x => x.Table).Returns(new List <DiscountRequirement>().AsQueryable()); var discountUsageHistoryRepo = new Mock <IRepository <DiscountUsageHistory> >(); var categoryRepo = new Mock <IRepository <Category> >(); categoryRepo.Setup(x => x.Table).Returns(new List <Category>().AsQueryable()); var manufacturerRepo = new Mock <IRepository <Manufacturer> >(); manufacturerRepo.Setup(x => x.Table).Returns(new List <Manufacturer>().AsQueryable()); var productRepo = new Mock <IRepository <Product> >(); productRepo.Setup(x => x.Table).Returns(new List <Product>().AsQueryable()); var customerService = new Mock <ICustomerService>(); var localizationService = new Mock <ILocalizationService>(); var eventPublisher = new Mock <IEventPublisher>(); var loger = new Mock <ILogger>(); var webHelper = new Mock <IWebHelper>(); var pluginService = new PluginService(new CatalogSettings(), customerService.Object, loger.Object, CommonHelper.DefaultFileProvider, webHelper.Object); var categoryService = new Mock <ICategoryService>(); var discountPluginManager = new DiscountPluginManager(pluginService); var store = new Store { Id = 1 }; var storeContext = new Mock <IStoreContext>(); storeContext.Setup(x => x.CurrentStore).Returns(store); var discountService = new TestDiscountService(categoryService.Object, customerService.Object, discountPluginManager, eventPublisher.Object, localizationService.Object, categoryRepo.Object, discountRepo.Object, discountRequirementRepo.Object, discountUsageHistoryRepo.Object, manufacturerRepo.Object, productRepo.Object, cacheManager, storeContext.Object); return(discountService); }
public static IDiscountService Init() { var _cacheManager = new TestMemoryCacheManager(new Mock <IMemoryCache>().Object); var _discountRepo = new Mock <IRepository <Discount> >(); var _complexDiscountRepo = new Mock <IRepository <ComplexDiscount> >(); var _discountRequirementRepo = new Mock <IRepository <DiscountRequirement> >(); _discountRequirementRepo.Setup(x => x.Table).Returns(new List <DiscountRequirement>().AsQueryable()); var _discountUsageHistoryRepo = new Mock <IRepository <DiscountUsageHistory> >(); var _categoryRepo = new Mock <IRepository <Category> >(); _categoryRepo.Setup(x => x.Table).Returns(new List <Category>().AsQueryable()); var _manufacturerRepo = new Mock <IRepository <Manufacturer> >(); _manufacturerRepo.Setup(x => x.Table).Returns(new List <Manufacturer>().AsQueryable()); var _productRepo = new Mock <IRepository <Product> >(); _productRepo.Setup(x => x.Table).Returns(new List <Product>().AsQueryable()); var _customerService = new Mock <ICustomerService>(); var _localizationService = new Mock <ILocalizationService>(); var _eventPublisher = new Mock <IEventPublisher>(); var pluginFinder = new PluginFinder(_eventPublisher.Object); var _categoryService = new Mock <ICategoryService>(); var _store = new Store { Id = 1 }; var _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(_store); var discountService = new TestDiscountService(_categoryService.Object, _customerService.Object, _eventPublisher.Object, _localizationService.Object, pluginFinder, _categoryRepo.Object, _discountRepo.Object, _complexDiscountRepo.Object, _discountRequirementRepo.Object, _discountUsageHistoryRepo.Object, _manufacturerRepo.Object, _productRepo.Object, _cacheManager, _storeContext.Object); return(discountService); }
public static IDiscountService Init(IQueryable <Discount> discounts = default, IQueryable <DiscountProductMapping> productDiscountMapping = null) { var staticCacheManager = new TestCacheManager(); var discountRepo = new FakeRepository <Discount>(discounts.ToList()); var discountRequirementRepo = new FakeRepository <DiscountRequirement>(); var discountUsageHistoryRepo = new FakeRepository <DiscountUsageHistory>(); var customerService = new Mock <ICustomerService>(); var localizationService = new Mock <ILocalizationService>(); var productService = new Mock <IProductService>(); var pluginService = new FakePluginService(); var discountPluginManager = new DiscountPluginManager(customerService.Object, pluginService); var store = new Store { Id = 1 }; var storeContext = new Mock <IStoreContext>(); storeContext.Setup(x => x.CurrentStore).Returns(store); var orderRepo = new FakeRepository <Order>(); var discountService = new TestDiscountService( customerService.Object, discountPluginManager, localizationService.Object, productService.Object, discountRepo, discountRequirementRepo, discountUsageHistoryRepo, orderRepo, staticCacheManager, storeContext.Object); return(discountService); }