public void IfTaxesAreEnabledButPricesIncludeTaxTheBasePriceShouldBeThePrice() { var pricingMethod = new ProductPricingMethodBuilder().LoadedPricesIncludeTax().Build(); var productVariant = new ProductVariantBuilder().WithBasePrice(1.00m).Build(); pricingMethod.GetUnitPrice(productVariant, 0m, 0m).Should().Be(1.00m); }
public void IfTaxesAreDisabledTheBasePriceShouldBeThePrice() { var pricingMethod = new ProductPricingMethodBuilder().TaxesDisabled().Build(); var productVariant = new ProductVariantBuilder().WithBasePrice(1.00m).Build(); pricingMethod.GetUnitPrice(productVariant, 0m, 0m).Should().Be(1.00m); }
public void IfPricesExcludeTaxTheyShouldBeAdded() { var pricingMethod = new ProductPricingMethodBuilder().LoadedPricesExcludeTax().Build(); var productVariant = new ProductVariantBuilder().WithBasePrice(1.00m).WithTaxPercentage(20m).Build(); pricingMethod.GetUnitPrice(productVariant, 0m, 0m).Should().Be(1.20m); }
public void PriceShouldBeCalculatedCorrectly(bool taxesEnabled, PriceLoadingMethod priceLoadingMethod, TaxCalculationMethod taxCalculationMethod, double basePrice, int quantity, double expected) { var pricingMethod = new ProductPricingMethodBuilder().TaxesEnabled(taxesEnabled) .WithPriceLoadingMethod(priceLoadingMethod) .WithTaxCalculationMethod(taxCalculationMethod).Build(); var productVariant = new ProductVariantBuilder().WithBasePrice(Convert.ToDecimal(basePrice)) .WithTaxPercentage(Convert.ToDecimal(TaxPercentage)) .Build(); var cartItemData = new CartItemBuilder().WithItem(productVariant).WithQuantity(quantity).Build(); pricingMethod.GetPrice(cartItemData).Should().Be(Convert.ToDecimal(expected)); }
private void DiscountApplicationOnPricePreTaxIsCorrectForSingleRowPriced(decimal basePrice, PriceLoadingMethod priceLoadingMethod, DiscountOnPrices discountOnPrices, ApplyCustomerTax applyCustomerTax, double expected) { var pricingMethod = new ProductPricingMethodBuilder().WithPriceLoadingMethod(priceLoadingMethod) .CalculateTaxOnRow() .WithDiscountOnPrices(discountOnPrices) .WithCustomerTaxApplication(applyCustomerTax) .Build(); var productVariant = new ProductVariantBuilder().WithBasePrice(basePrice) .WithTaxPercentage(TaxPercentage) .Build(); var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountAmount(1).Build(); pricingMethod.GetPricePreTax(cartItemData).Should().Be(Convert.ToDecimal(expected)); }
private void DiscountApplicationOnPricePreTaxIsCorrectForIndividuallyPriced(decimal basePrice, PriceLoadingMethod priceLoadingMethod, DiscountOnPrices discountOnPrices, ApplyCustomerTax applyCustomerTax, double expected) { var pricingMethod = new ProductPricingMethodBuilder().WithPriceLoadingMethod(priceLoadingMethod) .CalculateTaxOnIndividualItem() .WithDiscountOnPrices(discountOnPrices) .WithCustomerTaxApplication(applyCustomerTax) .Build(); var productVariant = new ProductVariantBuilder().WithBasePrice(basePrice) .WithTaxPercentage(TaxPercentage) .Build(); var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountPercentage(10).Build(); //check for various quantities - should be fine with individual item pricing to just multiply up for (int quantity = 1; quantity <= 10; quantity++) { cartItemData.Quantity = quantity; pricingMethod.GetPricePreTax(cartItemData).Should().Be(Convert.ToDecimal(expected * quantity)); } }