Ejemplo n.º 1
0
        public new void SetUp()
        {
            _discountRepo = MockRepository.GenerateMock <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.Expect(x => x.Table).Return(new List <Discount> {
                discount1, discount2
            }.AsQueryable());

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _workContext  = null;

            var cacheManager = new SiteNullCache();

            _discountRequirementRepo = MockRepository.GenerateMock <IRepository <DiscountRequirement> >();
            _discountRequirementRepo.Expect(x => x.Table).Return(new List <DiscountRequirement>().AsQueryable());

            _discountUsageHistoryRepo = MockRepository.GenerateMock <IRepository <DiscountUsageHistory> >();
            var pluginFinder = new PluginFinder();

            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();
            _localizationService     = MockRepository.GenerateMock <ILocalizationService>();
            _categoryService         = MockRepository.GenerateMock <ICategoryService>();
            _discountService         = new DiscountService(cacheManager, _discountRepo, _discountRequirementRepo,
                                                           _discountUsageHistoryRepo, _storeContext,
                                                           _localizationService, _categoryService, pluginFinder, _eventPublisher, _workContext);
        }
Ejemplo n.º 2
0
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");

            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _warehouseRepository      = MockRepository.GenerateMock <IRepository <Warehouse> >();
            _logger = new NullLogger();
            _productAttributeParser  = MockRepository.GenerateMock <IProductAttributeParser>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();

            var cacheManager = new SiteNullCache();

            var pluginFinder = new PluginFinder();

            _productService = MockRepository.GenerateMock <IProductService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService     = MockRepository.GenerateMock <ILocalizationService>();
            _addressService          = MockRepository.GenerateMock <IAddressService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();

            _store = new Store {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService      = new ShippingService(_shippingMethodRepository,
                                                        _warehouseRepository,
                                                        _logger,
                                                        _productService,
                                                        _productAttributeParser,
                                                        _checkoutAttributeParser,
                                                        _genericAttributeService,
                                                        _localizationService,
                                                        _addressService,
                                                        _shippingSettings,
                                                        pluginFinder,
                                                        _storeContext,
                                                        _eventPublisher,
                                                        _shoppingCartSettings,
                                                        cacheManager);
        }
        public new void SetUp()
        {
            _shippingSettings = new ShippingSettings();
            _shippingSettings.UseCubeRootMethod = true;
            _shippingSettings.ConsiderAssociatedProductsDimensions = true;

            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _warehouseRepository      = MockRepository.GenerateMock <IRepository <Warehouse> >();
            _logger = new NullLogger();
            _productAttributeParser  = MockRepository.GenerateMock <IProductAttributeParser>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();

            var cacheManager = new SiteNullCache();

            var pluginFinder = new PluginFinder();

            _productService = MockRepository.GenerateMock <IProductService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService     = MockRepository.GenerateMock <ILocalizationService>();
            _addressService          = MockRepository.GenerateMock <IAddressService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();

            _store = new Store {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            _shoppingCartSettings = new ShoppingCartSettings();
            _shippingService      = new ShippingService(_shippingMethodRepository,
                                                        _warehouseRepository,
                                                        _logger,
                                                        _productService,
                                                        _productAttributeParser,
                                                        _checkoutAttributeParser,
                                                        _genericAttributeService,
                                                        _localizationService,
                                                        _addressService,
                                                        _shippingSettings,
                                                        pluginFinder,
                                                        _storeContext,
                                                        _eventPublisher,
                                                        _shoppingCartSettings,
                                                        cacheManager);
        }
Ejemplo n.º 4
0
        public new void SetUp()
        {
            _languageRepo = MockRepository.GenerateMock <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.Expect(x => x.Table).Return(new List <Language> {
                lang1, lang2
            }.AsQueryable());

            _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>();

            var cacheManager = new SiteNullCache();

            _settingService = MockRepository.GenerateMock <ISettingService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationSettings = new LocalizationSettings();
            _languageService      = new LanguageService(cacheManager, _languageRepo, _storeMappingService,
                                                        _settingService, _localizationSettings, _eventPublisher);
        }
Ejemplo n.º 5
0
        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 = MockRepository.GenerateMock <IRepository <Currency> >();
            _currencyRepository.Expect(x => x.Table).Return(new List <Currency> {
                currencyUSD, currencyEUR, currencyRUR
            }.AsQueryable());
            _currencyRepository.Expect(x => x.GetById(currencyUSD.Id)).Return(currencyUSD);
            _currencyRepository.Expect(x => x.GetById(currencyEUR.Id)).Return(currencyEUR);
            _currencyRepository.Expect(x => x.GetById(currencyRUR.Id)).Return(currencyRUR);

            _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>();

            var cacheManager = new SiteNullCache();

            _currencySettings = new CurrencySettings();
            _currencySettings.PrimaryStoreCurrencyId        = currencyUSD.Id;
            _currencySettings.PrimaryExchangeRateCurrencyId = currencyEUR.Id;

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            var pluginFinder = new PluginFinder();

            _currencyService = new CurrencyService(cacheManager,
                                                   _currencyRepository, _storeMappingService,
                                                   _currencySettings, pluginFinder, _eventPublisher);
        }
Ejemplo n.º 6
0
        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 = MockRepository.GenerateMock <IRepository <MeasureDimension> >();
            _measureDimensionRepository.Expect(x => x.Table).Return(new List <MeasureDimension> {
                measureDimension1, measureDimension2, measureDimension3, measureDimension4
            }.AsQueryable());
            _measureDimensionRepository.Expect(x => x.GetById(measureDimension1.Id)).Return(measureDimension1);
            _measureDimensionRepository.Expect(x => x.GetById(measureDimension2.Id)).Return(measureDimension2);
            _measureDimensionRepository.Expect(x => x.GetById(measureDimension3.Id)).Return(measureDimension3);
            _measureDimensionRepository.Expect(x => x.GetById(measureDimension4.Id)).Return(measureDimension4);

            _measureWeightRepository = MockRepository.GenerateMock <IRepository <MeasureWeight> >();
            _measureWeightRepository.Expect(x => x.Table).Return(new List <MeasureWeight> {
                measureWeight1, measureWeight2, measureWeight3, measureWeight4
            }.AsQueryable());
            _measureWeightRepository.Expect(x => x.GetById(measureWeight1.Id)).Return(measureWeight1);
            _measureWeightRepository.Expect(x => x.GetById(measureWeight2.Id)).Return(measureWeight2);
            _measureWeightRepository.Expect(x => x.GetById(measureWeight3.Id)).Return(measureWeight3);
            _measureWeightRepository.Expect(x => x.GetById(measureWeight4.Id)).Return(measureWeight4);


            var cacheManager = new SiteNullCache();

            _measureSettings = new MeasureSettings();
            _measureSettings.BaseDimensionId = measureDimension1.Id; //inch(es)
            _measureSettings.BaseWeightId    = measureWeight2.Id;    //lb(s)

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _measureService = new MeasureService(cacheManager,
                                                 _measureDimensionRepository,
                                                 _measureWeightRepository,
                                                 _measureSettings, _eventPublisher);
        }
Ejemplo n.º 7
0
        public new void SetUp()
        {
            var cacheManager = new SiteNullCache();

            _workContext = MockRepository.GenerateMock <IWorkContext>();
            _workContext.Expect(w => w.WorkingCurrency).Return(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 = MockRepository.GenerateMock <IRepository <Currency> >();
            _currencyRepo.Expect(x => x.Table).Return(new List <Currency> {
                currency1, currency2
            }.AsQueryable());

            _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>();

            var pluginFinder = new PluginFinder();

            _currencyService = new CurrencyService(cacheManager, _currencyRepo, _storeMappingService,
                                                   _currencySettings, pluginFinder, null);

            _taxSettings = new TaxSettings();

            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _localizationService.Expect(x => x.GetResource("Products.InclTaxSuffix", 1, false)).Return("{0} incl tax");
            _localizationService.Expect(x => x.GetResource("Products.ExclTaxSuffix", 1, false)).Return("{0} excl tax");

            _priceFormatter = new PriceFormatter(_workContext, _currencyService, _localizationService,
                                                 _taxSettings, _currencySettings);

            var nopEngine        = MockRepository.GenerateMock <SiteEngine>();
            var containe         = MockRepository.GenerateMock <IContainer>();
            var containerManager = MockRepository.GenerateMock <ContainerManager>(containe);

            nopEngine.Expect(x => x.ContainerManager).Return(containerManager);
            containerManager.Expect(x => x.Resolve <IWorkContext>()).Return(_workContext);
            EngineContext.Replace(nopEngine);
        }
        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,
                CheckoutAttribute   = ca1,
                CheckoutAttributeId = ca1.Id,
            };
            cav1_2 = new CheckoutAttributeValue
            {
                Id                  = 12,
                Name                = "Red",
                DisplayOrder        = 2,
                CheckoutAttribute   = ca1,
                CheckoutAttributeId = ca1.Id,
            };
            ca1.CheckoutAttributeValues.Add(cav1_1);
            ca1.CheckoutAttributeValues.Add(cav1_2);

            //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,
                CheckoutAttribute   = ca2,
                CheckoutAttributeId = ca2.Id,
            };
            cav2_2 = new CheckoutAttributeValue
            {
                Id                  = 22,
                Name                = "Option 2",
                DisplayOrder        = 2,
                CheckoutAttribute   = ca2,
                CheckoutAttributeId = ca2.Id,
            };
            ca2.CheckoutAttributeValues.Add(cav2_1);
            ca2.CheckoutAttributeValues.Add(cav2_2);

            //custom text
            ca3 = new CheckoutAttribute
            {
                Id                   = 3,
                Name                 = "Custom text",
                TextPrompt           = "Enter custom text:",
                IsRequired           = true,
                AttributeControlType = AttributeControlType.MultilineTextbox,
                DisplayOrder         = 3,
            };


            #endregion

            _checkoutAttributeRepo = MockRepository.GenerateMock <IRepository <CheckoutAttribute> >();
            _checkoutAttributeRepo.Expect(x => x.Table).Return(new List <CheckoutAttribute> {
                ca1, ca2, ca3
            }.AsQueryable());
            _checkoutAttributeRepo.Expect(x => x.GetById(ca1.Id)).Return(ca1);
            _checkoutAttributeRepo.Expect(x => x.GetById(ca2.Id)).Return(ca2);
            _checkoutAttributeRepo.Expect(x => x.GetById(ca3.Id)).Return(ca3);

            _checkoutAttributeValueRepo = MockRepository.GenerateMock <IRepository <CheckoutAttributeValue> >();
            _checkoutAttributeValueRepo.Expect(x => x.Table).Return(new List <CheckoutAttributeValue> {
                cav1_1, cav1_2, cav2_1, cav2_2
            }.AsQueryable());
            _checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_1.Id)).Return(cav1_1);
            _checkoutAttributeValueRepo.Expect(x => x.GetById(cav1_2.Id)).Return(cav1_2);
            _checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_1.Id)).Return(cav2_1);
            _checkoutAttributeValueRepo.Expect(x => x.GetById(cav2_2.Id)).Return(cav2_2);

            var cacheManager = new SiteNullCache();

            _storeMappingService = MockRepository.GenerateMock <IStoreMappingService>();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _checkoutAttributeService = new CheckoutAttributeService(cacheManager,
                                                                     _checkoutAttributeRepo,
                                                                     _checkoutAttributeValueRepo,
                                                                     _storeMappingService,
                                                                     _eventPublisher);

            _checkoutAttributeParser = new CheckoutAttributeParser(_checkoutAttributeService);



            var workingLanguage = new Language();
            _workContext = MockRepository.GenerateMock <IWorkContext>();
            _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage);
            _currencyService = MockRepository.GenerateMock <ICurrencyService>();
            _taxService      = MockRepository.GenerateMock <ITaxService>();
            _priceFormatter  = MockRepository.GenerateMock <IPriceFormatter>();
            _downloadService = MockRepository.GenerateMock <IDownloadService>();
            _webHelper       = MockRepository.GenerateMock <IWebHelper>();

            _checkoutAttributeFormatter = new CheckoutAttributeFormatter(_workContext,
                                                                         _checkoutAttributeService,
                                                                         _checkoutAttributeParser,
                                                                         _currencyService,
                                                                         _taxService,
                                                                         _priceFormatter,
                                                                         _downloadService,
                                                                         _webHelper);
        }
Ejemplo n.º 9
0
        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 = MockRepository.GenerateMock <IRepository <ProductAttribute> >();
            _productAttributeRepo.Expect(x => x.Table).Return(new List <ProductAttribute> {
                pa1, pa2, pa3, pa4
            }.AsQueryable());
            _productAttributeRepo.Expect(x => x.GetById(pa1.Id)).Return(pa1);
            _productAttributeRepo.Expect(x => x.GetById(pa2.Id)).Return(pa2);
            _productAttributeRepo.Expect(x => x.GetById(pa3.Id)).Return(pa3);
            _productAttributeRepo.Expect(x => x.GetById(pa4.Id)).Return(pa4);

            _productAttributeMappingRepo = MockRepository.GenerateMock <IRepository <ProductAttributeMapping> >();
            _productAttributeMappingRepo.Expect(x => x.Table).Return(new List <ProductAttributeMapping> {
                pam1_1, pam2_1, pam3_1, pam4_1
            }.AsQueryable());
            _productAttributeMappingRepo.Expect(x => x.GetById(pam1_1.Id)).Return(pam1_1);
            _productAttributeMappingRepo.Expect(x => x.GetById(pam2_1.Id)).Return(pam2_1);
            _productAttributeMappingRepo.Expect(x => x.GetById(pam3_1.Id)).Return(pam3_1);
            _productAttributeMappingRepo.Expect(x => x.GetById(pam4_1.Id)).Return(pam4_1);

            _productAttributeCombinationRepo = MockRepository.GenerateMock <IRepository <ProductAttributeCombination> >();
            _productAttributeCombinationRepo.Expect(x => x.Table).Return(new List <ProductAttributeCombination>().AsQueryable());

            _productAttributeValueRepo = MockRepository.GenerateMock <IRepository <ProductAttributeValue> >();
            _productAttributeValueRepo.Expect(x => x.Table).Return(new List <ProductAttributeValue> {
                pav1_1, pav1_2, pav2_1, pav2_2, pav4_1
            }.AsQueryable());
            _productAttributeValueRepo.Expect(x => x.GetById(pav1_1.Id)).Return(pav1_1);
            _productAttributeValueRepo.Expect(x => x.GetById(pav1_2.Id)).Return(pav1_2);
            _productAttributeValueRepo.Expect(x => x.GetById(pav2_1.Id)).Return(pav2_1);
            _productAttributeValueRepo.Expect(x => x.GetById(pav2_2.Id)).Return(pav2_2);
            _productAttributeValueRepo.Expect(x => x.GetById(pav4_1.Id)).Return(pav4_1);

            _predefinedProductAttributeValueRepo = MockRepository.GenerateMock <IRepository <PredefinedProductAttributeValue> >();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            var cacheManager = new SiteNullCache();

            _productAttributeService = new ProductAttributeService(cacheManager,
                                                                   _productAttributeRepo,
                                                                   _productAttributeMappingRepo,
                                                                   _productAttributeCombinationRepo,
                                                                   _productAttributeValueRepo,
                                                                   _predefinedProductAttributeValueRepo,
                                                                   _eventPublisher);

            _context = MockRepository.GenerateMock <IDbContext>();

            _productAttributeParser = new ProductAttributeParser(_context, _productAttributeService);

            _priceCalculationService = MockRepository.GenerateMock <IPriceCalculationService>();

            var workingLanguage = new Language();
            _workContext = MockRepository.GenerateMock <IWorkContext>();
            _workContext.Expect(x => x.WorkingLanguage).Return(workingLanguage);
            _currencyService     = MockRepository.GenerateMock <ICurrencyService>();
            _localizationService = MockRepository.GenerateMock <ILocalizationService>();
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Virtual")).Return("For: {0} <{1}>");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Virtual")).Return("From: {0} <{1}>");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.For.Physical")).Return("For: {0}");
            _localizationService.Expect(x => x.GetResource("GiftCardAttribute.From.Physical")).Return("From: {0}");
            _taxService           = MockRepository.GenerateMock <ITaxService>();
            _priceFormatter       = MockRepository.GenerateMock <IPriceFormatter>();
            _downloadService      = MockRepository.GenerateMock <IDownloadService>();
            _webHelper            = MockRepository.GenerateMock <IWebHelper>();
            _shoppingCartSettings = MockRepository.GenerateMock <ShoppingCartSettings>();

            _productAttributeFormatter = new ProductAttributeFormatter(_workContext,
                                                                       _productAttributeService,
                                                                       _productAttributeParser,
                                                                       _currencyService,
                                                                       _localizationService,
                                                                       _taxService,
                                                                       _priceFormatter,
                                                                       _downloadService,
                                                                       _webHelper,
                                                                       _priceCalculationService,
                                                                       _shoppingCartSettings);
        }
Ejemplo n.º 10
0
        public new void SetUp()
        {
            _workContext = null;

            _store = new Store {
                Id = 1
            };
            _storeContext = MockRepository.GenerateMock <IStoreContext>();
            _storeContext.Expect(x => x.CurrentStore).Return(_store);

            var pluginFinder = new PluginFinder();

            _shoppingCartSettings = new ShoppingCartSettings();
            _catalogSettings      = new CatalogSettings();

            var cacheManager = new SiteNullCache();

            _productService = MockRepository.GenerateMock <IProductService>();

            //price calculation service
            _discountService     = MockRepository.GenerateMock <IDiscountService>();
            _categoryService     = MockRepository.GenerateMock <ICategoryService>();
            _manufacturerService = MockRepository.GenerateMock <IManufacturerService>();

            _productAttributeParser = MockRepository.GenerateMock <IProductAttributeParser>();
            _priceCalcService       = new PriceCalculationService(_workContext, _storeContext,
                                                                  _discountService, _categoryService, _manufacturerService,
                                                                  _productAttributeParser, _productService,
                                                                  cacheManager, _shoppingCartSettings, _catalogSettings);

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _localizationService = MockRepository.GenerateMock <ILocalizationService>();

            //shipping
            _shippingSettings = new ShippingSettings();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames = new List <string>();
            _shippingSettings.ActiveShippingRateComputationMethodSystemNames.Add("FixedRateTestShippingRateComputationMethod");
            _shippingMethodRepository = MockRepository.GenerateMock <IRepository <ShippingMethod> >();
            _warehouseRepository      = MockRepository.GenerateMock <IRepository <Warehouse> >();
            _logger          = new NullLogger();
            _shippingService = new ShippingService(_shippingMethodRepository,
                                                   _warehouseRepository,
                                                   _logger,
                                                   _productService,
                                                   _productAttributeParser,
                                                   _checkoutAttributeParser,
                                                   _genericAttributeService,
                                                   _localizationService,
                                                   _addressService,
                                                   _shippingSettings,
                                                   pluginFinder,
                                                   _storeContext,
                                                   _eventPublisher,
                                                   _shoppingCartSettings,
                                                   cacheManager);
            _shipmentService = MockRepository.GenerateMock <IShipmentService>();


            _paymentService          = MockRepository.GenerateMock <IPaymentService>();
            _checkoutAttributeParser = MockRepository.GenerateMock <ICheckoutAttributeParser>();
            _giftCardService         = MockRepository.GenerateMock <IGiftCardService>();
            _genericAttributeService = MockRepository.GenerateMock <IGenericAttributeService>();

            _geoLookupService     = MockRepository.GenerateMock <IGeoLookupService>();
            _countryService       = MockRepository.GenerateMock <ICountryService>();
            _stateProvinceService = MockRepository.GenerateMock <IStateProvinceService>();
            _customerSettings     = new CustomerSettings();
            _addressSettings      = new AddressSettings();

            //tax
            _taxSettings = new TaxSettings();
            _taxSettings.ShippingIsTaxable = true;
            _taxSettings.PaymentMethodAdditionalFeeIsTaxable = true;
            _taxSettings.DefaultTaxAddressId = 10;
            _addressService = MockRepository.GenerateMock <IAddressService>();
            _addressService.Expect(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Return(new Address {
                Id = _taxSettings.DefaultTaxAddressId
            });
            _taxService = new TaxService(_addressService, _workContext, _storeContext, _taxSettings,
                                         pluginFinder, _geoLookupService, _countryService, _stateProvinceService, _logger,
                                         _customerSettings, _shippingSettings, _addressSettings);

            _rewardPointService   = MockRepository.GenerateMock <IRewardPointService>();
            _rewardPointsSettings = new RewardPointsSettings();

            _orderTotalCalcService = new OrderTotalCalculationService(_workContext, _storeContext,
                                                                      _priceCalcService, _taxService, _shippingService, _paymentService,
                                                                      _checkoutAttributeParser, _discountService, _giftCardService,
                                                                      _genericAttributeService, _rewardPointService,
                                                                      _taxSettings, _rewardPointsSettings, _shippingSettings, _shoppingCartSettings, _catalogSettings);

            _orderService               = MockRepository.GenerateMock <IOrderService>();
            _webHelper                  = MockRepository.GenerateMock <IWebHelper>();
            _languageService            = MockRepository.GenerateMock <ILanguageService>();
            _priceFormatter             = MockRepository.GenerateMock <IPriceFormatter>();
            _productAttributeFormatter  = MockRepository.GenerateMock <IProductAttributeFormatter>();
            _shoppingCartService        = MockRepository.GenerateMock <IShoppingCartService>();
            _checkoutAttributeFormatter = MockRepository.GenerateMock <ICheckoutAttributeFormatter>();
            _customerService            = MockRepository.GenerateMock <ICustomerService>();
            _encryptionService          = MockRepository.GenerateMock <IEncryptionService>();
            _workflowMessageService     = MockRepository.GenerateMock <IWorkflowMessageService>();
            _customerActivityService    = MockRepository.GenerateMock <ICustomerActivityService>();
            _currencyService            = MockRepository.GenerateMock <ICurrencyService>();
            _affiliateService           = MockRepository.GenerateMock <IAffiliateService>();
            _vendorService              = MockRepository.GenerateMock <IVendorService>();
            _pdfService                 = MockRepository.GenerateMock <IPdfService>();
            _customNumberFormatter      = MockRepository.GenerateMock <ICustomNumberFormatter>();

            _paymentSettings = new PaymentSettings
            {
                ActivePaymentMethodSystemNames = new List <string>
                {
                    "Payments.TestMethod"
                }
            };
            _orderSettings = new OrderSettings();

            _localizationSettings = new LocalizationSettings();

            _eventPublisher = MockRepository.GenerateMock <IEventPublisher>();
            _eventPublisher.Expect(x => x.Publish(Arg <object> .Is.Anything));

            _rewardPointService = MockRepository.GenerateMock <IRewardPointService>();
            _currencySettings   = new CurrencySettings();

            _orderProcessingService = new OrderProcessingService(_orderService, _webHelper,
                                                                 _localizationService, _languageService,
                                                                 _productService, _paymentService, _logger,
                                                                 _orderTotalCalcService, _priceCalcService, _priceFormatter,
                                                                 _productAttributeParser, _productAttributeFormatter,
                                                                 _giftCardService, _shoppingCartService, _checkoutAttributeFormatter,
                                                                 _shippingService, _shipmentService, _taxService,
                                                                 _customerService, _discountService,
                                                                 _encryptionService, _workContext,
                                                                 _workflowMessageService, _vendorService,
                                                                 _customerActivityService, _currencyService, _affiliateService,
                                                                 _eventPublisher, _pdfService, _rewardPointService,
                                                                 _genericAttributeService,
                                                                 _countryService, _stateProvinceService,
                                                                 _shippingSettings, _paymentSettings, _rewardPointsSettings,
                                                                 _orderSettings, _taxSettings, _localizationSettings,
                                                                 _currencySettings, _customNumberFormatter);
        }