public TestDiscountService(ICategoryService categoryService, ICustomerService customerService, IDiscountPluginManager discountPluginManager, IEventPublisher eventPublisher, ILocalizationService localizationService, IRepository <Category> categoryRepository, IRepository <Discount> discountRepository, IRepository <DiscountRequirement> discountRequirementRepository, IRepository <DiscountUsageHistory> discountUsageHistoryRepository, IRepository <Manufacturer> manufacturerRepository, IRepository <Product> productRepository, IStaticCacheManager cacheManager, IStoreContext storeContext) : base(categoryService, customerService, discountPluginManager, eventPublisher, localizationService, categoryRepository, discountRepository, discountRequirementRepository, discountUsageHistoryRepository, manufacturerRepository, productRepository, cacheManager, storeContext) { _discountForCaching = new List <DiscountForCaching>(); }
public DiscountModelFactory(CurrencySettings currencySettings, IBaseAdminModelFactory baseAdminModelFactory, ICategoryService categoryService, ICurrencyService currencyService, IDateTimeHelper dateTimeHelper, IDiscountPluginManager discountPluginManager, IDiscountService discountService, ILocalizationService localizationService, IManufacturerService manufacturerService, IOrderService orderService, IPriceFormatter priceFormatter, IProductService productService, IUrlRecordService urlRecordService, IWebHelper webHelper) { _currencySettings = currencySettings; _baseAdminModelFactory = baseAdminModelFactory; _categoryService = categoryService; _currencyService = currencyService; _dateTimeHelper = dateTimeHelper; _discountPluginManager = discountPluginManager; _discountService = discountService; _localizationService = localizationService; _manufacturerService = manufacturerService; _orderService = orderService; _priceFormatter = priceFormatter; _productService = productService; _urlRecordService = urlRecordService; _webHelper = webHelper; }
public DiscountService(ICacheKeyService cacheKeyService, ICustomerService customerService, IDiscountPluginManager discountPluginManager, IEventPublisher eventPublisher, ILocalizationService localizationService, IProductService productService, IRepository <Discount> discountRepository, IRepository <DiscountRequirement> discountRequirementRepository, IRepository <DiscountUsageHistory> discountUsageHistoryRepository, IRepository <Order> orderRepository, IStaticCacheManager staticCacheManager, IStoreContext storeContext) { _cacheKeyService = cacheKeyService; _customerService = customerService; _discountPluginManager = discountPluginManager; _eventPublisher = eventPublisher; _localizationService = localizationService; _productService = productService; _discountRepository = discountRepository; _discountRequirementRepository = discountRequirementRepository; _discountUsageHistoryRepository = discountUsageHistoryRepository; _orderRepository = orderRepository; _staticCacheManager = staticCacheManager; _storeContext = storeContext; }
public TestDiscountService(ICacheKeyService cacheKeyService, ICustomerService customerService, IDiscountPluginManager discountPluginManager, IEventPublisher eventPublisher, ILocalizationService localizationService, IProductService productService, IRepository <Discount> discountRepository, IRepository <DiscountRequirement> discountRequirementRepository, IRepository <DiscountUsageHistory> discountUsageHistoryRepository, IRepository <Order> orderRepository, IStaticCacheManager staticCacheManager, IStoreContext storeContext) : base( cacheKeyService, customerService, discountPluginManager, eventPublisher, localizationService, productService, discountRepository, discountRequirementRepository, discountUsageHistoryRepository, orderRepository, staticCacheManager, storeContext) { _discounts = new List <Discount>(); }
public override void SetUp() { rm = new List <CustomerCustomerRoleMapping> { new CustomerCustomerRoleMapping { CustomerRoleId = _customerRoleRegistered.Id, CustomerId = 1 }, new CustomerCustomerRoleMapping { CustomerRoleId = _customerRoleAdmin.Id, CustomerId = 1 } }.AsQueryable(); _discountRepo.Setup(x => x.Table).Returns(Discounts().AsQueryable()); _discountRepo.Setup(c => c.GetById(It.IsAny <int>())).Returns((int i) => Discounts().FirstOrDefault(c => c.Id == i)); _discountRequirementRepo.Setup(x => x.Table).Returns(DiscountRequirements().AsQueryable()); _discountRequirementRepo.Setup(dr => dr.Insert(It.IsAny <DiscountRequirement>())).Callback((DiscountRequirement i) => { i.Id = DiscountRequirements().Count() > 0 ? DiscountRequirements().Max(x => x.Id) + 1 : 1; DiscountRequirements().Add(i); }); _customerCustomerRoleMapping.Setup(x => x.Table).Returns(rm); _customerService.Setup(x => x.GetCustomerRoles(It.IsAny <Customer>(), false)).Returns((Customer i, bool f) => { var roles = Roles().Where(y => rm.Where(x => x.CustomerId == i.Id).Select(x => x.CustomerRoleId).Contains(y.Id)); return(roles.ToList()); }); var pluginService = new FakePluginService(customerService: _customerService.Object); _discountPluginManager = new DiscountPluginManager(_customerService.Object, pluginService); }
public DiscountService(ICategoryService categoryService, ICustomerService customerService, IDiscountPluginManager discountPluginManager, IEventPublisher eventPublisher, ILocalizationService localizationService, IRepository <Category> categoryRepository, IRepository <Discount> discountRepository, IRepository <DiscountRequirement> discountRequirementRepository, IRepository <DiscountUsageHistory> discountUsageHistoryRepository, IRepository <Manufacturer> manufacturerRepository, IRepository <Product> productRepository, IStaticCacheManager cacheManager, IStoreContext storeContext) { _categoryService = categoryService; _customerService = customerService; _discountPluginManager = discountPluginManager; _eventPublisher = eventPublisher; _localizationService = localizationService; _categoryRepository = categoryRepository; _discountRepository = discountRepository; _discountRequirementRepository = discountRequirementRepository; _discountUsageHistoryRepository = discountUsageHistoryRepository; _manufacturerRepository = manufacturerRepository; _productRepository = productRepository; _cacheManager = cacheManager; _storeContext = storeContext; }
public FakeDiscountService(ICacheKeyService cacheKeyService = null, ICustomerService customerService = null, IDiscountPluginManager discountPluginManager = null, IEventPublisher eventPublisher = null, ILocalizationService localizationService = null, IProductService productService = null, IRepository <Discount> discountRepository = null, IRepository <DiscountRequirement> discountRequirementRepository = null, IRepository <DiscountUsageHistory> discountUsageHistoryRepository = null, IRepository <Order> orderRepository = null, IStaticCacheManager staticCacheManager = null, IStoreContext storeContext = null) : base( cacheKeyService ?? new FakeCacheKeyService(), customerService ?? new Mock <ICustomerService>().Object, discountPluginManager ?? new Mock <IDiscountPluginManager>().Object, eventPublisher ?? new Mock <IEventPublisher>().Object, localizationService ?? new Mock <ILocalizationService>().Object, productService ?? new Mock <IProductService>().Object, discountRepository.FakeRepoNullPropagation(), discountRequirementRepository.FakeRepoNullPropagation(), discountUsageHistoryRepository.FakeRepoNullPropagation(), orderRepository.FakeRepoNullPropagation(), staticCacheManager ?? new TestCacheManager(), storeContext ?? new Mock <IStoreContext>().Object) { }
public new void SetUp() { var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0 }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3 }; _discountRepo.Setup(x => x.Table).Returns(new List <Discount> { discount1, discount2 }.AsQueryable()); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); _categoryRepo.Setup(x => x.Table).Returns(new List <Category>().AsQueryable()); _manufacturerRepo.Setup(x => x.Table).Returns(new List <Manufacturer>().AsQueryable()); _productRepo.Setup(x => x.Table).Returns(new List <Product>().AsQueryable()); var staticCacheManager = new TestCacheManager(); _discountRequirementRepo.Setup(x => x.Table).Returns(new List <DiscountRequirement>().AsQueryable()); var pluginService = new FakePluginService(); _discountPluginManager = new DiscountPluginManager(new FakeCacheKeyService(), new Mock <ICustomerService>().Object, pluginService); _discountService = new DiscountService( new FakeCacheKeyService(), _customerService.Object, _discountPluginManager, _eventPublisher.Object, _localizationService.Object, _productService.Object, _discountRepo.Object, _discountRequirementRepo.Object, _discountUsageHistoryRepo.Object, _orderRepo.Object, staticCacheManager, _storeContext.Object); }
public new void SetUp() { var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0 }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3 }; _discountRepo = new FakeRepository <Discount>(new List <Discount> { discount1, discount2 }); var staticCacheManager = new TestCacheManager(); var pluginService = new FakePluginService(); _discountPluginManager = new DiscountPluginManager(new Mock <ICustomerService>().Object, pluginService); _discountService = new DiscountService( _customerService.Object, _discountPluginManager, _localizationService.Object, _productService.Object, _discountRepo.GetRepository(), _discountRequirementRepo, _discountUsageHistoryRepo, _orderRepo, staticCacheManager, _storeContext.Object); }
public DiscountController(CatalogSettings catalogSettings, ICategoryService categoryService, ICustomerActivityService customerActivityService, IDiscountModelFactory discountModelFactory, IDiscountPluginManager discountPluginManager, IDiscountService discountService, ILocalizationService localizationService, IManufacturerService manufacturerService, INotificationService notificationService, IPermissionService permissionService, IProductService productService) { _catalogSettings = catalogSettings; _categoryService = categoryService; _customerActivityService = customerActivityService; _discountModelFactory = discountModelFactory; _discountPluginManager = discountPluginManager; _discountService = discountService; _localizationService = localizationService; _manufacturerService = manufacturerService; _notificationService = notificationService; _permissionService = permissionService; _productService = productService; }
public void SetUp() { _discountPluginManager = GetService <IDiscountPluginManager>(); _discountService = GetService <IDiscountService>(); }
public override void SetUp() { var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", CouponCode = "DiscoutCoupon", RequiresCouponCode = true, UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0 }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3 }; var discountList = new List <Discount> { discount1, discount2 }.AsQueryable(); var discountRequirement = new List <DiscountRequirement>().AsQueryable(); _permissionService.Setup(x => x.Authorize(StandardPermissionProvider.ManageDiscounts)).Returns(true); _discountRepo.Setup(x => x.Table).Returns(discountList); _discountRepo.Setup(c => c.GetById(It.IsAny <int>())).Returns((int i) => discountList.FirstOrDefault(c => c.Id == i)); _discountRequirementRepo.Setup(x => x.Table).Returns(discountRequirement); _discountRequirementRepo.Setup(dr => dr.Insert(It.IsAny <DiscountRequirement>())).Callback((DiscountRequirement i) => { i.Id = discountRequirement.Count() > 0 ? discountRequirement.Max(x => x.Id) + 1 : 1; discountRequirement.ToList().Add(i); }); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var staticCacheManager = new TestCacheManager(); var pluginService = new FakePluginService(); _discountPluginManager = new DiscountPluginManager(new Mock <ICustomerService>().Object, pluginService); _discountService = new DiscountService( new FakeCacheKeyService(), _customerService.Object, _discountPluginManager, _eventPublisher.Object, _localizationService.Object, _productService.Object, _discountRepo.Object, _discountRequirementRepo.Object, _discountUsageHistoryRepo.Object, _orderRepo.Object, staticCacheManager, _storeContext.Object); }
public new void SetUp() { _discountRepo = new Mock <IRepository <Discount> >(); var discount1 = new Discount { Id = 1, DiscountType = DiscountType.AssignedToCategories, Name = "Discount 1", UsePercentage = true, DiscountPercentage = 10, DiscountAmount = 0, DiscountLimitation = DiscountLimitationType.Unlimited, LimitationTimes = 0 }; var discount2 = new Discount { Id = 2, DiscountType = DiscountType.AssignedToSkus, Name = "Discount 2", UsePercentage = false, DiscountPercentage = 0, DiscountAmount = 5, RequiresCouponCode = true, CouponCode = "SecretCode", DiscountLimitation = DiscountLimitationType.NTimesPerCustomer, LimitationTimes = 3 }; _discountRepo.Setup(x => x.Table).Returns(new List <Discount> { discount1, discount2 }.AsQueryable()); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); _storeContext = new Mock <IStoreContext>(); _customerService = new Mock <ICustomerService>(); _categoryRepo = new Mock <IRepository <Category> >(); _categoryRepo.Setup(x => x.Table).Returns(new List <Category>().AsQueryable()); _manufacturerRepo = new Mock <IRepository <Manufacturer> >(); _manufacturerRepo.Setup(x => x.Table).Returns(new List <Manufacturer>().AsQueryable()); _productRepo = new Mock <IRepository <Product> >(); _productRepo.Setup(x => x.Table).Returns(new List <Product>().AsQueryable()); var cacheManager = new TestCacheManager(); _discountRequirementRepo = new Mock <IRepository <DiscountRequirement> >(); _discountRequirementRepo.Setup(x => x.Table).Returns(new List <DiscountRequirement>().AsQueryable()); _discountUsageHistoryRepo = new Mock <IRepository <DiscountUsageHistory> >(); var loger = new Mock <ILogger>(); var webHelper = new Mock <IWebHelper>(); _catalogSettings = new CatalogSettings(); var pluginService = new PluginService(_catalogSettings, _customerService.Object, loger.Object, CommonHelper.DefaultFileProvider, webHelper.Object); _localizationService = new Mock <ILocalizationService>(); _categoryService = new Mock <ICategoryService>(); _discountPluginManager = new DiscountPluginManager(pluginService); _discountService = new DiscountService(_categoryService.Object, _customerService.Object, _discountPluginManager, _eventPublisher.Object, _localizationService.Object, _categoryRepo.Object, _discountRepo.Object, _discountRequirementRepo.Object, _discountUsageHistoryRepo.Object, _manufacturerRepo.Object, _productRepo.Object, cacheManager, _storeContext.Object); }