public void Can_load_active_taxProvider() { var serviceProvider = new FakeServiceProvider(_genericAttributeService.Object, _taxService, _taxSettings); var nopEngine = new FakeNopEngine(serviceProvider); EngineContext.Replace(nopEngine); var provider = _taxPluginManager.LoadPrimaryPlugin(); provider.Should().NotBeNull(); EngineContext.Replace(null); }
public void Can_get_productPrice_priceIncludesTax_includingTax_taxable() { var customer = new Customer(); var product = new Product(); var serviceProvider = new FakeServiceProvider(_genericAttributeService.Object, _taxService, _taxSettings); var nopEngine = new FakeNopEngine(serviceProvider); EngineContext.Replace(nopEngine); _taxService.GetProductPrice(product, 0, 1000M, true, customer, true, out _).Should().Be(1000); _taxService.GetProductPrice(product, 0, 1000M, true, customer, false, out _).Should().Be(1100); _taxService.GetProductPrice(product, 0, 1000M, false, customer, true, out _).Should() .Be(909.0909090909090909090909091M); _taxService.GetProductPrice(product, 0, 1000M, false, customer, false, out _).Should().Be(1000); EngineContext.Replace(null); }
public void CheckRequirement_restrictedRoleId_Valid() { var serviceProvider = new FakeServiceProvider(_customerService.Object); var nopEngine = new FakeNopEngine(serviceProvider); EngineContext.Replace(nopEngine); var rule = _discountPluginManager.LoadPluginBySystemName(SystemName); var result = rule.CheckRequirement(new DiscountRequirementValidationRequest() { DiscountRequirementId = 1, Store = null, Customer = new Customer() { Id = 1 } }); Assert.IsInstanceOf <DiscountRequirementValidationResult>(result); Assert.AreEqual(result.IsValid, true); EngineContext.Replace(null); }
public OrderTotalCalculationServiceTests() { _shippingSettings = new ShippingSettings { ActiveShippingRateComputationMethodSystemNames = new List <string> { "FixedRateTestShippingRateComputationMethod" }, AllowPickupInStore = true, IgnoreAdditionalShippingChargeForPickupInStore = false }; _taxSettings = new TaxSettings { ShippingIsTaxable = true, PaymentMethodAdditionalFeeIsTaxable = true, DefaultTaxAddressId = 10 }; var products = new List <Product> { new Product { Id = 1, Weight = 1.5M, Height = 2.5M, Length = 3.5M, Width = 4.5M, AdditionalShippingCharge = 5.5M, IsShipEnabled = true }, new Product { Id = 2, Weight = 11.5M, Height = 12.5M, Length = 13.5M, Width = 14.5M, AdditionalShippingCharge = 6.5M, IsShipEnabled = true }, new Product { Id = 3, Weight = 11.5M, Height = 12.5M, Length = 13.5M, Width = 14.5M, AdditionalShippingCharge = 7.5M, IsShipEnabled = false } }; var productRepository = _fakeDataStore.RegRepository(products); _productService = new FakeProductService(productRepository: productRepository); var store = new Store { Id = 1 }; _storeContext.Setup(x => x.CurrentStore).Returns(store); _currencyService.Setup(x => x.GetCurrencyById(1)).Returns(new Currency { Id = 1, RoundingTypeId = 0 }); _addressService.Setup(x => x.GetAddressById(_taxSettings.DefaultTaxAddressId)).Returns(new Address { Id = _taxSettings.DefaultTaxAddressId }); _paymentService.Setup(ps => ps.GetAdditionalHandlingFee(It.IsAny <IList <ShoppingCartItem> >(), "test1")).Returns(20); _genericAttributeService.Setup(x => x.GetAttribute <PickupPoint>(It.IsAny <Customer>(), NopCustomerDefaults.SelectedPickupPointAttribute, _storeContext.Object.CurrentStore.Id, null)) .Returns(new PickupPoint()); _genericAttributeService.Setup(x => x.GetAttribute <string>(It.IsAny <Customer>(), NopCustomerDefaults.SelectedPaymentMethodAttribute, _storeContext.Object.CurrentStore.Id, null)) .Returns("test1"); _customerRoleRepository = _fakeDataStore.RegRepository(new[] { new CustomerRole { Id = 1, Active = true, FreeShipping = true }, new CustomerRole { Id = 2, Active = true, FreeShipping = false } }); var customerRepository = _fakeDataStore.RegRepository(new[] { new Customer() { Id = 1 } }); var customerCustomerRoleMappingRepository = _fakeDataStore.RegRepository <CustomerCustomerRoleMapping>(); _customerService = new FakeCustomerService( customerRepository: customerRepository, customerRoleRepository: _customerRoleRepository, customerCustomerRoleMappingRepository: customerCustomerRoleMappingRepository, storeContext: _storeContext.Object); var pluginService = new FakePluginService(); var pickupPluginManager = new PickupPluginManager(_customerService, pluginService, _shippingSettings); _shippingPluginManager = new ShippingPluginManager(_customerService, pluginService, _shippingSettings); var taxPluginManager = new TaxPluginManager(_customerService, pluginService, _taxSettings); var discountPluginManager = new DiscountPluginManager(_customerService, pluginService); var currencySettings = new CurrencySettings { PrimaryStoreCurrencyId = 1 }; var discountRepository = _fakeDataStore.RegRepository <Discount>(); _discountService = new FakeDiscountService( customerService: _customerService, discountPluginManager: discountPluginManager, productService: _productService, discountRepository: discountRepository, storeContext: _storeContext.Object); IPriceCalculationService priceCalculationService = new FakePriceCalculationService( currencySettings: currencySettings, currencyService: _currencyService.Object, customerService: _customerService, discountService: _discountService, productService: _productService, storeContext: _storeContext.Object); _shoppingCartService = new FakeShoppingCartService( productService: _productService, customerService: _customerService, genericAttributeService: _genericAttributeService.Object, priceCalculationService: priceCalculationService, shoppingCartSettings: _shoppingCartSettings); IShippingService shippingService = new FakeShippingService(customerSerice: _customerService, genericAttributeService: _genericAttributeService.Object, pickupPluginManager: pickupPluginManager, productService: _productService, shippingPluginManager: _shippingPluginManager, storeContext: _storeContext.Object, shippingSettings: _shippingSettings); _taxService = new FakeTaxService( addressService: _addressService.Object, customerService: _customerService, genericAttributeService: _genericAttributeService.Object, storeContext: _storeContext.Object, taxPluginManager: taxPluginManager, shippingSettings: _shippingSettings, taxSettings: _taxSettings); _orderTotalCalcService = new FakeOrderTotalCalculationService( addressService: _addressService.Object, customerService: _customerService, discountService: _discountService, genericAttributeService: _genericAttributeService.Object, paymentService: _paymentService.Object, priceCalculationService: priceCalculationService, productService: _productService, shippingPluginManager: _shippingPluginManager, shippingService: shippingService, shoppingCartService: _shoppingCartService, storeContext: _storeContext.Object, taxService: _taxService, shippingSettings: _shippingSettings, taxSettings: _taxSettings, rewardPointsSettings: _rewardPointsSettings); var serviceProvider = new FakeServiceProvider(_shoppingCartService, _paymentService.Object, _genericAttributeService.Object, _orderTotalCalcService, _taxService, _taxSettings); var nopEngine = new FakeNopEngine(serviceProvider); EngineContext.Replace(nopEngine); }