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 IfInStockAndCartItemAmountIsWithinStockRemainingShouldReturnCanBuy()
        {
            ProductVariant variant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service = new ProductVariantAvailabilityServiceBuilder().Build();

            service.CanBuy(variant, 2).Should().BeOfType <CanBuy>();
        }
Beispiel #3
0
        public void IfStockIsTrackedAVariantWithSomeStockRemainingStockShouldBeInStock()
        {
            ProductVariant productVariant = new ProductVariantBuilder().StockRemaining(1).Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(1).Build();

            productStockChecker.IsInStock(productVariant).Should().BeTrue();
        }
Beispiel #4
0
        public void IfProductDoesNotHaveRestrictedShippingItCanShip()
        {
            var productVariant = new ProductVariantBuilder().WithUnrestrictedShipping().Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().Build();

            productShippingChecker.CanShip(productVariant).Should().BeTrue();
        }
Beispiel #5
0
        public void UntrackedVariantsAreAlwaysInStock()
        {
            ProductVariant productVariant = new ProductVariantBuilder().DoNotTrackStock().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().Build();

            productStockChecker.IsInStock(productVariant).Should().BeTrue();
        }
Beispiel #6
0
        public void IfStockIsTrackedAVariantWithZeroRemainingStockShouldNotBeInStock()
        {
            ProductVariant productVariant = new ProductVariantBuilder().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(0).Build();

            productStockChecker.IsInStock(productVariant).Should().BeFalse();
        }
        public void IfStockIsTrackedAVariantWithSomeStockRemainingStockShouldBeInStock()
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().StockRemaining(1).Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(1).Build();

            productStockChecker.IsInStock(productVariant).Should().BeTrue();
        }
        public void IfStockIsTrackedAVariantWithZeroRemainingStockShouldNotBeInStock()
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(0).Build();

            productStockChecker.IsInStock(productVariant).Should().BeFalse();
        }
        public void UntrackedVariantsAreAlwaysInStock()
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().DoNotTrackStock().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().Build();

            productStockChecker.IsInStock(productVariant).Should().BeTrue();
        }
Beispiel #10
0
        public void IfProductDoesHaveRestrictedShippingAndThereAreNoShippingTypesAvailableShouldNotShip()
        {
            var productVariant = new ProductVariantBuilder().WithRestrictedShipping().Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().Build();

            productShippingChecker.CanShip(productVariant).Should().BeFalse();
        }
        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);
        }
Beispiel #12
0
        public void UntrackedVariantsAreAvailableInAnyQuantity()
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().DoNotTrackStock().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().Build();

            productStockChecker.CanOrderQuantity(productVariant, 999).CanOrder.Should().BeTrue();
        }
        public void UntrackedVariantsAreAvailableInAnyQuantity()
        {
            ProductVariant productVariant = new ProductVariantBuilder().DoNotTrackStock().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().Build();

            productStockChecker.CanOrderQuantity(productVariant, 999).CanOrder.Should().BeTrue();
        }
Beispiel #14
0
        public void IfProductDoesNotHaveRestrictedShippingItCanShip()
        {
            var productVariant         = new ProductVariantBuilder().WithUnrestrictedShipping().Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().Build();

            productShippingChecker.CanShip(productVariant).Should().BeTrue();
        }
        public void IfTheStockLevelIsBelowTheRequestedAmountItShouldBeReturned()
        {
            ProductVariant productVariant = new ProductVariantBuilder().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(1).Build();

            productStockChecker.CanOrderQuantity(productVariant, 2).StockRemaining.Should().Be(1);
        }
        public void IfInStockAndCartItemAmountIsWithinStockRemainingShouldReturnCanBuy()
        {
            ProductVariant variant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service = new ProductVariantAvailabilityServiceBuilder().Build();

            service.CanBuy(variant, 2).Should().BeOfType<CanBuy>();
        }
        public void IfStockIsTrackedAVariantWithEqualOrMoreThanTheRequestedAmountShouldBeAvailable(int remaining)
        {
            ProductVariant productVariant = new ProductVariantBuilder().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(remaining).Build();

            productStockChecker.CanOrderQuantity(productVariant, 2).CanOrder.Should().BeTrue();
        }
Beispiel #18
0
        public void IfStockIsTrackedAVariantWithEqualOrMoreThanTheRequestedAmountShouldBeAvailable(int remaining)
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(remaining).Build();

            productStockChecker.CanOrderQuantity(productVariant, 2).CanOrder.Should().BeTrue();
        }
        public void IfStockIsTrackedAVariantWithLessThanTheRequestedAmountShouldNotBeAvailable()
        {
            ProductVariant productVariant = new ProductVariantBuilder().StockRemaining(1).Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().Build();

            productStockChecker.CanOrderQuantity(productVariant, 2).CanOrder.Should().BeFalse();
        }
Beispiel #20
0
        public void IfTheStockLevelIsBelowTheRequestedAmountItShouldBeReturned()
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().StockRemaining(1).Build();

            productStockChecker.CanOrderQuantity(productVariant, 2).StockRemaining.Should().Be(1);
        }
Beispiel #21
0
        public void IfProductDoesHaveRestrictedShippingAndThereAreNoShippingTypesAvailableShouldNotShip()
        {
            var productVariant         = new ProductVariantBuilder().WithRestrictedShipping().Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().Build();

            productShippingChecker.CanShip(productVariant).Should().BeFalse();
        }
        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);
        }
Beispiel #23
0
        public void IfStockIsTrackedAVariantWithLessThanTheRequestedAmountShouldNotBeAvailable()
        {
            ProductVariant      productVariant      = new ProductVariantBuilder().StockRemaining(1).Build();
            ProductStockChecker productStockChecker = new ProductStockCheckerBuilder().Build();

            productStockChecker.CanOrderQuantity(productVariant, 2).CanOrder.Should().BeFalse();
        }
        public void IfCannotShipShouldReturnNoShippingMethodWouldBeAvailable()
        {
            ProductVariant variant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service =
                new ProductVariantAvailabilityServiceBuilder().CannotShip().Build();

            service.CanBuy(variant, 1).Should().BeOfType<NoShippingMethodWouldBeAvailable>();
        }
        public void IfInStockButCannotPurchaseTheRequestedAmountShouldReturnAnUnableToOrderQuantityStatus()
        {
            ProductVariant variant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service = new ProductVariantAvailabilityServiceBuilder().
                CannotOrderQuantity().Build();

            service.CanBuy(variant, 2).Should().BeOfType<CannotOrderQuantity>();
        }
        public void IfOutOfStockShouldReturnAnOutOfStockStatus()
        {
            ProductVariant productVariant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service = new ProductVariantAvailabilityServiceBuilder()
                .IsOutOfStock().Build();

            service.CanBuy(productVariant, 1).Should().BeOfType<OutOfStock>();
        }
        public void IfCannotShipShouldReturnNoShippingMethodWouldBeAvailable()
        {
            ProductVariant variant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service =
                new ProductVariantAvailabilityServiceBuilder().CannotShip().Build();

            service.CanBuy(variant, 1).Should().BeOfType <NoShippingMethodWouldBeAvailable>();
        }
        public void IfOutOfStockShouldReturnAnOutOfStockStatus()
        {
            ProductVariant productVariant             = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service = new ProductVariantAvailabilityServiceBuilder()
                                                        .IsOutOfStock().Build();

            service.CanBuy(productVariant, 1).Should().BeOfType <OutOfStock>();
        }
        public void IfInStockButCannotPurchaseTheRequestedAmountShouldReturnAnUnableToOrderQuantityStatus()
        {
            ProductVariant variant = new ProductVariantBuilder().Build();
            ProductVariantAvailabilityService service = new ProductVariantAvailabilityServiceBuilder().
                                                        CannotOrderQuantity().Build();

            service.CanBuy(variant, 2).Should().BeOfType <CannotOrderQuantity>();
        }
Beispiel #30
0
        public void IfRestrictedShippingAndCartModelAndProductVariantHaveMatchingShippingMethodsCanShip()
        {
            var method = new StubShippingMethod1();
            var productVariant = new ProductVariantBuilder().WithRestrictedShipping(method.TypeName).Build();
            var cartModel = new CartModelBuilder().WithShippingOptions(method).Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().WithCartModel(cartModel).Build();

            productShippingChecker.CanShip(productVariant).Should().BeTrue();
        }
Beispiel #31
0
        public void IfRestrictedShippingAndCartModelAndProductVariantHaveMatchingShippingMethodsCanShip()
        {
            var method                 = new StubShippingMethod1();
            var productVariant         = new ProductVariantBuilder().WithRestrictedShipping(method.TypeName).Build();
            var cartModel              = new CartModelBuilder().WithShippingOptions(method).Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().WithCartModel(cartModel).Build();

            productShippingChecker.CanShip(productVariant).Should().BeTrue();
        }
Beispiel #32
0
        public void IfRestrictedShippingAndCartModelAndProductVariantHaveNoSharedShippingMethodsCannotShip()
        {
            var method1 = new StubShippingMethod1();
            var method2 = new StubShippingMethod2();
            var productVariant = new ProductVariantBuilder().WithRestrictedShipping(method1.TypeName).Build();
            var cartModel = new CartModelBuilder().WithShippingOptions(method2).Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().WithCartModel(cartModel).Build();

            productShippingChecker.CanShip(productVariant).Should().BeFalse();
        }
        private static CartItemData GetCartItemData(decimal basePrice)
        {
            var productVariant =
                new ProductVariantBuilder().WithBasePrice(basePrice)
                .WithTaxPercentage(TaxPercentage)
                .Build();
            var cartItemData = new CartItemBuilder().WithItem(productVariant).WithDiscountPercentage(10).Build();

            return(cartItemData);
        }
Beispiel #34
0
        public void IfRestrictedShippingAndCartModelAndProductVariantHaveNoSharedShippingMethodsCannotShip()
        {
            var method1                = new StubShippingMethod1();
            var method2                = new StubShippingMethod2();
            var productVariant         = new ProductVariantBuilder().WithRestrictedShipping(method1.TypeName).Build();
            var cartModel              = new CartModelBuilder().WithShippingOptions(method2).Build();
            var productShippingChecker = new ProductShippingCheckerBuilder().WithCartModel(cartModel).Build();

            productShippingChecker.CanShip(productVariant).Should().BeFalse();
        }
        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));
        }
Beispiel #37
0
        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));
            }
        }