public new void SetUp() { _taxSettings = new TaxSettings { DefaultTaxAddressId = 10 }; _workContext = null; _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(new Store { Id = 1 }); _addressService = new Mock <IAddressService>(); //default tax address _addressService.Setup(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Returns(new Address { Id = _taxSettings.DefaultTaxAddressId }); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); _geoLookupService = new Mock <IGeoLookupService>(); _countryService = new Mock <ICountryService>(); _stateProvinceService = new Mock <IStateProvinceService>(); _logger = new Mock <ILogger>(); _webHelper = new Mock <IWebHelper>(); _genericAttributeService = new Mock <IGenericAttributeService>(); _customerSettings = new CustomerSettings(); _shippingSettings = new ShippingSettings(); _addressSettings = new AddressSettings(); var customerService = new Mock <ICustomerService>(); var loger = new Mock <ILogger>(); _catalogSettings = new CatalogSettings(); var pluginService = new PluginService(_catalogSettings, customerService.Object, loger.Object, CommonHelper.DefaultFileProvider, _webHelper.Object); _taxPluginManager = new TaxPluginManager(pluginService, _taxSettings); var cacheManager = new TestCacheManager(); _taxService = new TaxService(_addressSettings, _customerSettings, _addressService.Object, _countryService.Object, _genericAttributeService.Object, _geoLookupService.Object, _logger.Object, _stateProvinceService.Object, cacheManager, _storeContext.Object, _taxPluginManager, _webHelper.Object, _workContext, _shippingSettings, _taxSettings); }
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 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 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 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); }
public new void SetUp() { _languageRepo = new Mock <IRepository <Language> >(); var lang1 = new Language { Name = "English", LanguageCulture = "en-Us", FlagImageFileName = "us.png", Published = true, DisplayOrder = 1 }; var lang2 = new Language { Name = "Russian", LanguageCulture = "ru-Ru", FlagImageFileName = "ru.png", Published = true, DisplayOrder = 2 }; _languageRepo.Setup(x => x.Table).Returns(new List <Language> { lang1, lang2 }.AsQueryable()); _storeMappingService = new Mock <IStoreMappingService>(); var cacheManager = new TestCacheManager(); _settingService = new Mock <ISettingService>(); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); _localizationSettings = new LocalizationSettings(); _languageService = new LanguageService(_eventPublisher.Object, _languageRepo.Object, _settingService.Object, cacheManager, _storeMappingService.Object, _localizationSettings); }
public new void SetUp() { #region Test data //color (dropdownlist) pa1 = new ProductAttribute { Id = 1, Name = "Color" }; pam1_1 = new ProductAttributeMapping { Id = 11, ProductId = 1, TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa1.Id }; pav1_1 = new ProductAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, ProductAttributeMapping = pam1_1, ProductAttributeMappingId = pam1_1.Id }; pav1_2 = new ProductAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, ProductAttributeMapping = pam1_1, ProductAttributeMappingId = pam1_1.Id }; pam1_1.ProductAttributeValues.Add(pav1_1); pam1_1.ProductAttributeValues.Add(pav1_2); //custom option (checkboxes) pa2 = new ProductAttribute { Id = 2, Name = "Some custom option" }; pam2_1 = new ProductAttributeMapping { Id = 21, ProductId = 1, TextPrompt = "Select at least one option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2, ProductAttribute = pa2, ProductAttributeId = pa2.Id }; pav2_1 = new ProductAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, ProductAttributeMapping = pam2_1, ProductAttributeMappingId = pam2_1.Id }; pav2_2 = new ProductAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, ProductAttributeMapping = pam2_1, ProductAttributeMappingId = pam2_1.Id }; pam2_1.ProductAttributeValues.Add(pav2_1); pam2_1.ProductAttributeValues.Add(pav2_2); //custom text pa3 = new ProductAttribute { Id = 3, Name = "Custom text" }; pam3_1 = new ProductAttributeMapping { Id = 31, ProductId = 1, TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.TextBox, DisplayOrder = 1, ProductAttribute = pa1, ProductAttributeId = pa3.Id }; //option radio pa4 = new ProductAttribute { Id = 4, Name = "Radio list" }; pam4_1 = new ProductAttributeMapping { Id = 41, ProductId = 1, TextPrompt = "Select option and enter the quantity:", IsRequired = true, AttributeControlType = AttributeControlType.RadioList, DisplayOrder = 2, ProductAttribute = pa4, ProductAttributeId = pa4.Id }; pav4_1 = new ProductAttributeValue { Id = 41, Name = "Option with quantity", DisplayOrder = 1, ProductAttributeMapping = pam4_1, ProductAttributeMappingId = pam4_1.Id }; #endregion _productAttributeRepo = new Mock <IRepository <ProductAttribute> >(); _productAttributeRepo.Setup(x => x.Table).Returns(new List <ProductAttribute> { pa1, pa2, pa3, pa4 }.AsQueryable()); _productAttributeRepo.Setup(x => x.GetById(pa1.Id)).Returns(pa1); _productAttributeRepo.Setup(x => x.GetById(pa2.Id)).Returns(pa2); _productAttributeRepo.Setup(x => x.GetById(pa3.Id)).Returns(pa3); _productAttributeRepo.Setup(x => x.GetById(pa4.Id)).Returns(pa4); _productAttributeMappingRepo = new Mock <IRepository <ProductAttributeMapping> >(); _productAttributeMappingRepo.Setup(x => x.Table).Returns(new List <ProductAttributeMapping> { pam1_1, pam2_1, pam3_1, pam4_1 }.AsQueryable()); _productAttributeMappingRepo.Setup(x => x.GetById(pam1_1.Id)).Returns(pam1_1); _productAttributeMappingRepo.Setup(x => x.GetById(pam2_1.Id)).Returns(pam2_1); _productAttributeMappingRepo.Setup(x => x.GetById(pam3_1.Id)).Returns(pam3_1); _productAttributeMappingRepo.Setup(x => x.GetById(pam4_1.Id)).Returns(pam4_1); _productAttributeCombinationRepo = new Mock <IRepository <ProductAttributeCombination> >(); _productAttributeCombinationRepo.Setup(x => x.Table).Returns(new List <ProductAttributeCombination>().AsQueryable()); _productAttributeValueRepo = new Mock <IRepository <ProductAttributeValue> >(); _productAttributeValueRepo.Setup(x => x.Table).Returns(new List <ProductAttributeValue> { pav1_1, pav1_2, pav2_1, pav2_2, pav4_1 }.AsQueryable()); _productAttributeValueRepo.Setup(x => x.GetById(pav1_1.Id)).Returns(pav1_1); _productAttributeValueRepo.Setup(x => x.GetById(pav1_2.Id)).Returns(pav1_2); _productAttributeValueRepo.Setup(x => x.GetById(pav2_1.Id)).Returns(pav2_1); _productAttributeValueRepo.Setup(x => x.GetById(pav2_2.Id)).Returns(pav2_2); _productAttributeValueRepo.Setup(x => x.GetById(pav4_1.Id)).Returns(pav4_1); _predefinedProductAttributeValueRepo = new Mock <IRepository <PredefinedProductAttributeValue> >(); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var cacheManager = new TestCacheManager(); _productAttributeService = new ProductAttributeService(cacheManager, _eventPublisher.Object, _predefinedProductAttributeValueRepo.Object, _productAttributeRepo.Object, _productAttributeCombinationRepo.Object, _productAttributeMappingRepo.Object, _productAttributeValueRepo.Object, new TestCacheManager()); _context = new Mock <IDbContext>(); _productAttributeParser = new ProductAttributeParser(_context.Object, _productAttributeService); _priceCalculationService = new Mock <IPriceCalculationService>(); var workingLanguage = new Language(); _workContext = new Mock <IWorkContext>(); _workContext.Setup(x => x.WorkingLanguage).Returns(workingLanguage); _currencyService = new Mock <ICurrencyService>(); _localizationService = TestLocalizationService.Init(); _taxService = new Mock <ITaxService>(); _priceFormatter = new Mock <IPriceFormatter>(); _downloadService = new Mock <IDownloadService>(); _webHelper = new Mock <IWebHelper>(); _shoppingCartSettings = new ShoppingCartSettings(); _productAttributeFormatter = new ProductAttributeFormatter(_currencyService.Object, _downloadService.Object, _localizationService, _priceCalculationService.Object, _priceFormatter.Object, _productAttributeParser, _taxService.Object, _webHelper.Object, _workContext.Object, _shoppingCartSettings); }
public new void SetUp() { _productService = new Mock <IProductService>(); _discountService = new Mock <IDiscountService>(); _categoryService = new Mock <ICategoryService>(); _manufacturerService = new Mock <IManufacturerService>(); _productAttributeParser = new Mock <IProductAttributeParser>(); _eventPublisher = new Mock <IEventPublisher>(); _localizationService = new Mock <ILocalizationService>(); _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >(); _warehouseRepository = new Mock <IRepository <Warehouse> >(); _shipmentService = new Mock <IShipmentService>(); _paymentService = new Mock <IPaymentService>(); _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>(); _giftCardService = new Mock <IGiftCardService>(); _genericAttributeService = new Mock <IGenericAttributeService>(); _geoLookupService = new Mock <IGeoLookupService>(); _countryService = new Mock <ICountryService>(); _stateProvinceService = new Mock <IStateProvinceService>(); _eventPublisher = new Mock <IEventPublisher>(); _addressService = new Mock <IAddressService>(); _rewardPointService = new Mock <IRewardPointService>(); _webHelper = new Mock <IWebHelper>(); _languageService = new Mock <ILanguageService>(); _priceFormatter = new Mock <IPriceFormatter>(); _productAttributeFormatter = new Mock <IProductAttributeFormatter>(); _shoppingCartService = new Mock <IShoppingCartService>(); _checkoutAttributeFormatter = new Mock <ICheckoutAttributeFormatter>(); _customerService = new Mock <ICustomerService>(); _encryptionService = new Mock <IEncryptionService>(); _workflowMessageService = new Mock <IWorkflowMessageService>(); _customerActivityService = new Mock <ICustomerActivityService>(); _currencyService = new Mock <ICurrencyService>(); _affiliateService = new Mock <IAffiliateService>(); _vendorService = new Mock <IVendorService>(); _pdfService = new Mock <IPdfService>(); _customNumberFormatter = new Mock <ICustomNumberFormatter>(); _rewardPointService = new Mock <IRewardPointService>(); _workContext = null; //setup _storeContext = new Mock <IStoreContext>(); _store = new Store { Id = 1 }; _storeContext.Setup(x => x.CurrentStore).Returns(_store); _catalogSettings = new CatalogSettings(); var cacheManager = new TestCacheManager(); _currencySettings = new CurrencySettings(); //price calculation service _priceCalcService = new PriceCalculationService(_catalogSettings, _currencySettings, _categoryService.Object, _currencyService.Object, _customerService.Object, _discountService.Object, _manufacturerService.Object, _productAttributeParser.Object, _productService.Object, cacheManager, _storeContext.Object, _workContext); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var pluginService = new FakePluginService(_catalogSettings); _paymentPluginManager = new PaymentPluginManager(pluginService, null, _paymentSettings); _pickupPluginManager = new PickupPluginManager(pluginService, _shippingSettings); _shippingPluginManager = new ShippingPluginManager(pluginService, _shippingSettings); _taxPluginManager = new TaxPluginManager(pluginService, _taxSettings); _shoppingCartSettings = new ShoppingCartSettings(); //shipping _shippingSettings = new ShippingSettings { ActiveShippingRateComputationMethodSystemNames = new List <string>() }; _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _logger = new NullLogger(); _customerSettings = new CustomerSettings(); _addressSettings = new AddressSettings(); var shippingMethodCountryMappingRepository = new Mock <IRepository <ShippingMethodCountryMapping> >(); _shippingService = new ShippingService(_addressService.Object, _checkoutAttributeParser.Object, _countryService.Object, _customerService.Object, _eventPublisher.Object, _genericAttributeService.Object, _localizationService.Object, _logger, _pickupPluginManager, _priceCalcService, _productAttributeParser.Object, _productService.Object, _shippingMethodRepository.Object, shippingMethodCountryMappingRepository.Object, _warehouseRepository.Object, _shippingPluginManager, _stateProvinceService.Object, _storeContext.Object, _shippingSettings, _shoppingCartSettings); //tax _taxSettings = new TaxSettings { ShippingIsTaxable = true, PaymentMethodAdditionalFeeIsTaxable = true, DefaultTaxAddressId = 10 }; _addressService.Setup(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Returns(new Address { Id = _taxSettings.DefaultTaxAddressId }); _taxService = new TaxService(_addressSettings, _customerSettings, _addressService.Object, _countryService.Object, _customerService.Object, _genericAttributeService.Object, _geoLookupService.Object, _logger, _stateProvinceService.Object, _storeContext.Object, _taxPluginManager, _webHelper.Object, _workContext, _shippingSettings, _taxSettings); _rewardPointsSettings = new RewardPointsSettings(); _recurringPaymentRepository = new Mock <IRepository <RecurringPayment> >(); var recurringPayments = new List <RecurringPayment>(); _recurringPaymentRepository.Setup(r => r.Insert(It.IsAny <RecurringPayment>())).Callback((RecurringPayment rph) => recurringPayments.Add(rph)); _recurringPaymentRepository.Setup(r => r.Table).Returns(recurringPayments.AsQueryable()); _recurringPaymentHistoryRepository = new Mock <IRepository <RecurringPaymentHistory> >(); var recurringPaymentHistory = new List <RecurringPaymentHistory>(); _recurringPaymentHistoryRepository.Setup(r => r.Insert(It.IsAny <RecurringPaymentHistory>())).Callback((RecurringPaymentHistory rph) => recurringPaymentHistory.Add(rph)); _recurringPaymentHistoryRepository.Setup(r => r.Table).Returns(recurringPaymentHistory.AsQueryable()); _orderService = new OrderService(_eventPublisher.Object, null, null, null, null, null, null, null, null, _recurringPaymentRepository.Object, _recurringPaymentHistoryRepository.Object, _shipmentService.Object); _orderTotalCalcService = new OrderTotalCalculationService(_catalogSettings, _addressService.Object, _checkoutAttributeParser.Object, _customerService.Object, _discountService.Object, _genericAttributeService.Object, _giftCardService.Object, _orderService, _paymentService.Object, _priceCalcService, _productService.Object, _rewardPointService.Object, _shippingPluginManager, _shippingService, _shoppingCartService.Object, _storeContext.Object, _taxService, _workContext, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _taxSettings); _paymentSettings = new PaymentSettings { ActivePaymentMethodSystemNames = new List <string> { "Payments.TestMethod" } }; _orderSettings = new OrderSettings(); _localizationSettings = new LocalizationSettings(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); _orderProcessingService = new OrderProcessingService(_currencySettings, _addressService.Object, _affiliateService.Object, _checkoutAttributeFormatter.Object, _countryService.Object, _currencyService.Object, _customerActivityService.Object, _customerService.Object, _customNumberFormatter.Object, _discountService.Object, _encryptionService.Object, _eventPublisher.Object, _genericAttributeService.Object, _giftCardService.Object, _languageService.Object, _localizationService.Object, _logger, _orderService, _orderTotalCalcService, _paymentPluginManager, _paymentService.Object, _pdfService.Object, _priceCalcService, _priceFormatter.Object, _productAttributeFormatter.Object, _productAttributeParser.Object, _productService.Object, _rewardPointService.Object, _shipmentService.Object, _shippingPluginManager, _shippingService, _shoppingCartService.Object, _stateProvinceService.Object, _storeContext.Object, _taxService, _vendorService.Object, _webHelper.Object, _workContext, _workflowMessageService.Object, _localizationSettings, _orderSettings, _paymentSettings, _rewardPointsSettings, _shippingSettings, _taxSettings); }
public new void SetUp() { #region Test data //color (dropdownlist) ca1 = new CheckoutAttribute { Id = 1, Name = "Color", TextPrompt = "Select color:", IsRequired = true, AttributeControlType = AttributeControlType.DropdownList, DisplayOrder = 1 }; cav1_1 = new CheckoutAttributeValue { Id = 11, Name = "Green", DisplayOrder = 1, CheckoutAttributeId = ca1.Id }; cav1_2 = new CheckoutAttributeValue { Id = 12, Name = "Red", DisplayOrder = 2, CheckoutAttributeId = ca1.Id }; //custom option (checkboxes) ca2 = new CheckoutAttribute { Id = 2, Name = "Custom option", TextPrompt = "Select custom option:", IsRequired = true, AttributeControlType = AttributeControlType.Checkboxes, DisplayOrder = 2 }; cav2_1 = new CheckoutAttributeValue { Id = 21, Name = "Option 1", DisplayOrder = 1, CheckoutAttributeId = ca2.Id }; cav2_2 = new CheckoutAttributeValue { Id = 22, Name = "Option 2", DisplayOrder = 2, CheckoutAttributeId = ca2.Id }; //custom text ca3 = new CheckoutAttribute { Id = 3, Name = "Custom text", TextPrompt = "Enter custom text:", IsRequired = true, AttributeControlType = AttributeControlType.MultilineTextbox, DisplayOrder = 3 }; #endregion _checkoutAttributeRepo = new FakeRepository <CheckoutAttribute>(new List <CheckoutAttribute> { ca1, ca2, ca3 }); _checkoutAttributeValueRepo = new FakeRepository <CheckoutAttributeValue>(new List <CheckoutAttributeValue> { cav1_1, cav1_2, cav2_1, cav2_2 }); var staticCacheManager = new TestCacheManager(); _storeMappingService = new Mock <IStoreMappingService>(); _checkoutAttributeService = new CheckoutAttributeService(staticCacheManager, _checkoutAttributeRepo, _checkoutAttributeValueRepo, _storeMappingService.Object); _checkoutAttributeParser = new CheckoutAttributeParser(_checkoutAttributeService); var workingLanguage = new Language(); _workContext = new Mock <IWorkContext>(); _workContext.Setup(x => x.WorkingLanguage).Returns(workingLanguage); _currencyService = new Mock <ICurrencyService>(); _taxService = new Mock <ITaxService>(); _priceFormatter = new Mock <IPriceFormatter>(); _downloadService = new Mock <IDownloadService>(); _webHelper = new Mock <IWebHelper>(); _localizationService = TestLocalizationService.Init(); //_localizationService.Setup(ls=>ls.GetLocalized(It.IsAny<CheckoutAttribute>(), attribute => attribute.Name, It.IsAny<int?>(), true, true)).Returns() _checkoutAttributeFormatter = new CheckoutAttributeFormatter(_checkoutAttributeParser, _checkoutAttributeService, _currencyService.Object, _downloadService.Object, _localizationService, _priceFormatter.Object, _taxService.Object, _webHelper.Object, _workContext.Object); }
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() { _shippingSettings = new ShippingSettings { ActiveShippingRateComputationMethodSystemNames = new List <string>() }; _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod"); _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >(); _warehouseRepository = new Mock <IRepository <Warehouse> >(); _logger = new NullLogger(); _productAttributeParser = new Mock <IProductAttributeParser>(); _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>(); var cacheManager = new TestCacheManager(); _productService = new Mock <IProductService>(); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var customerService = new Mock <ICustomerService>(); 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); _pickupPluginManager = new PickupPluginManager(pluginService, _shippingSettings); _shippingPluginManager = new ShippingPluginManager(pluginService, _shippingSettings); _localizationService = new Mock <ILocalizationService>(); _addressService = new Mock <IAddressService>(); _genericAttributeService = new Mock <IGenericAttributeService>(); _priceCalcService = new Mock <IPriceCalculationService>(); _store = new Store { Id = 1 }; _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(_store); _shoppingCartSettings = new ShoppingCartSettings(); _shippingService = new ShippingService(_addressService.Object, cacheManager, _checkoutAttributeParser.Object, _eventPublisher.Object, _genericAttributeService.Object, _localizationService.Object, _logger, _pickupPluginManager, _priceCalcService.Object, _productAttributeParser.Object, _productService.Object, _shippingMethodRepository.Object, _warehouseRepository.Object, _shippingPluginManager, _storeContext.Object, _shippingSettings, _shoppingCartSettings); }
public new void SetUp() { measureDimension1 = new MeasureDimension { Id = 1, Name = "inch(es)", SystemKeyword = "inches", Ratio = 1M, DisplayOrder = 1 }; measureDimension2 = new MeasureDimension { Id = 2, Name = "feet", SystemKeyword = "feet", Ratio = 0.08333333M, DisplayOrder = 2 }; measureDimension3 = new MeasureDimension { Id = 3, Name = "meter(s)", SystemKeyword = "meters", Ratio = 0.0254M, DisplayOrder = 3 }; measureDimension4 = new MeasureDimension { Id = 4, Name = "millimetre(s)", SystemKeyword = "millimetres", Ratio = 25.4M, DisplayOrder = 4 }; measureWeight1 = new MeasureWeight { Id = 1, Name = "ounce(s)", SystemKeyword = "ounce", Ratio = 16M, DisplayOrder = 1 }; measureWeight2 = new MeasureWeight { Id = 2, Name = "lb(s)", SystemKeyword = "lb", Ratio = 1M, DisplayOrder = 2 }; measureWeight3 = new MeasureWeight { Id = 3, Name = "kg(s)", SystemKeyword = "kg", Ratio = 0.45359237M, DisplayOrder = 3 }; measureWeight4 = new MeasureWeight { Id = 4, Name = "gram(s)", SystemKeyword = "grams", Ratio = 453.59237M, DisplayOrder = 4 }; _measureDimensionRepository = new Mock <IRepository <MeasureDimension> >(); _measureDimensionRepository.Setup(x => x.Table).Returns(new List <MeasureDimension> { measureDimension1, measureDimension2, measureDimension3, measureDimension4 }.AsQueryable()); _measureDimensionRepository.Setup(x => x.GetById(measureDimension1.Id)).Returns(measureDimension1); _measureDimensionRepository.Setup(x => x.GetById(measureDimension2.Id)).Returns(measureDimension2); _measureDimensionRepository.Setup(x => x.GetById(measureDimension3.Id)).Returns(measureDimension3); _measureDimensionRepository.Setup(x => x.GetById(measureDimension4.Id)).Returns(measureDimension4); _measureWeightRepository = new Mock <IRepository <MeasureWeight> >(); _measureWeightRepository.Setup(x => x.Table).Returns(new List <MeasureWeight> { measureWeight1, measureWeight2, measureWeight3, measureWeight4 }.AsQueryable()); _measureWeightRepository.Setup(x => x.GetById(measureWeight1.Id)).Returns(measureWeight1); _measureWeightRepository.Setup(x => x.GetById(measureWeight2.Id)).Returns(measureWeight2); _measureWeightRepository.Setup(x => x.GetById(measureWeight3.Id)).Returns(measureWeight3); _measureWeightRepository.Setup(x => x.GetById(measureWeight4.Id)).Returns(measureWeight4); var cacheManager = new TestCacheManager(); _measureSettings = new MeasureSettings { BaseDimensionId = measureDimension1.Id, //inch(es) BaseWeightId = measureWeight2.Id //lb(s) }; _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); _measureService = new MeasureService(cacheManager, _eventPublisher.Object, _measureDimensionRepository.Object, _measureWeightRepository.Object, _measureSettings); }
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); }
public new void SetUp() { currencyUSD = new Currency { Id = 1, Name = "US Dollar", CurrencyCode = "USD", Rate = 1.2M, DisplayLocale = "en-US", CustomFormatting = "", Published = true, DisplayOrder = 1, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, RoundingType = RoundingType.Rounding001 }; currencyEUR = new Currency { Id = 2, Name = "Euro", CurrencyCode = "EUR", Rate = 1, DisplayLocale = "", CustomFormatting = "€0.00", Published = true, DisplayOrder = 2, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, RoundingType = RoundingType.Rounding001 }; currencyRUR = new Currency { Id = 3, Name = "Russian Rouble", CurrencyCode = "RUB", Rate = 34.5M, DisplayLocale = "ru-RU", CustomFormatting = "", Published = true, DisplayOrder = 3, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow, RoundingType = RoundingType.Rounding001 }; _currencyRepository = new Mock <IRepository <Currency> >(); _currencyRepository.Setup(x => x.Table).Returns(new List <Currency> { currencyUSD, currencyEUR, currencyRUR }.AsQueryable()); _currencyRepository.Setup(x => x.GetById(currencyUSD.Id)).Returns(currencyUSD); _currencyRepository.Setup(x => x.GetById(currencyEUR.Id)).Returns(currencyEUR); _currencyRepository.Setup(x => x.GetById(currencyRUR.Id)).Returns(currencyRUR); _storeMappingService = new Mock <IStoreMappingService>(); var cacheManager = new TestCacheManager(); _currencySettings = new CurrencySettings { PrimaryStoreCurrencyId = currencyUSD.Id, PrimaryExchangeRateCurrencyId = currencyEUR.Id }; _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var customerService = new Mock <ICustomerService>(); 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); _exchangeRatePluginManager = new ExchangeRatePluginManager(_currencySettings, pluginService); _currencyService = new CurrencyService(_currencySettings, _eventPublisher.Object, _exchangeRatePluginManager, _currencyRepository.Object, cacheManager, _storeMappingService.Object); }
public new void SetUp() { _shippingSettings = new ShippingSettings { UseCubeRootMethod = true, ConsiderAssociatedProductsDimensions = true, ShipSeparatelyOneItemEach = false }; _shippingMethodRepository = new Mock <IRepository <ShippingMethod> >(); _warehouseRepository = new Mock <IRepository <Warehouse> >(); _logger = new NullLogger(); _productAttributeParser = new Mock <IProductAttributeParser>(); _checkoutAttributeParser = new Mock <ICheckoutAttributeParser>(); var cacheManager = new TestCacheManager(); _productService = new Mock <IProductService>(); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var customerService = new Mock <ICustomerService>(); 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); _pickupPluginManager = new PickupPluginManager(pluginService, _shippingSettings); _shippingPluginManager = new ShippingPluginManager(pluginService, _shippingSettings); _localizationService = new Mock <ILocalizationService>(); _addressService = new Mock <IAddressService>(); _genericAttributeService = new Mock <IGenericAttributeService>(); _priceCalcService = new Mock <IPriceCalculationService>(); _store = new Store { Id = 1 }; _storeContext = new Mock <IStoreContext>(); _storeContext.Setup(x => x.CurrentStore).Returns(_store); _shoppingCartSettings = new ShoppingCartSettings(); _shippingService = new ShippingService(_addressService.Object, cacheManager, _checkoutAttributeParser.Object, _eventPublisher.Object, _genericAttributeService.Object, _localizationService.Object, _logger, _pickupPluginManager, _priceCalcService.Object, _productAttributeParser.Object, _productService.Object, _shippingMethodRepository.Object, _warehouseRepository.Object, _shippingPluginManager, _storeContext.Object, _shippingSettings, _shoppingCartSettings); }
public new void SetUp() { var cacheManager = new TestCacheManager(); _workContext = new Mock <IWorkContext>(); _workContext.Setup(w => w.WorkingCurrency).Returns(new Currency { RoundingType = RoundingType.Rounding001 }); _currencySettings = new CurrencySettings(); var currency1 = new Currency { Id = 1, Name = "Euro", CurrencyCode = "EUR", DisplayLocale = "", CustomFormatting = "€0.00", DisplayOrder = 1, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; var currency2 = new Currency { Id = 1, Name = "US Dollar", CurrencyCode = "USD", DisplayLocale = "en-US", CustomFormatting = "", DisplayOrder = 2, Published = true, CreatedOnUtc = DateTime.UtcNow, UpdatedOnUtc = DateTime.UtcNow }; _currencyRepo = new Mock <IRepository <Currency> >(); _currencyRepo.Setup(x => x.Table).Returns(new List <Currency> { currency1, currency2 }.AsQueryable()); _storeMappingService = new Mock <IStoreMappingService>(); _measureService = new Mock <IMeasureService>(); _eventPublisher = new Mock <IEventPublisher>(); _eventPublisher.Setup(x => x.Publish(It.IsAny <object>())); var customerService = new Mock <ICustomerService>(); 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); _exchangeRatePluginManager = new ExchangeRatePluginManager(_currencySettings, pluginService); _currencyService = new CurrencyService(_currencySettings, null, _exchangeRatePluginManager, _currencyRepo.Object, cacheManager, _storeMappingService.Object); _taxSettings = new TaxSettings(); _localizationService = new Mock <ILocalizationService>(); _localizationService.Setup(x => x.GetResource("Products.InclTaxSuffix", 1, false, string.Empty, false)).Returns("{0} incl tax"); _localizationService.Setup(x => x.GetResource("Products.ExclTaxSuffix", 1, false, string.Empty, false)).Returns("{0} excl tax"); _priceFormatter = new PriceFormatter(_currencySettings, _currencyService, _localizationService.Object, _measureService.Object, _workContext.Object, _taxSettings); var nopEngine = new Mock <QNetEngine>(); nopEngine.Setup(x => x.ServiceProvider).Returns(new TestServiceProvider()); EngineContext.Replace(nopEngine.Object); }