public void Can_get_final_product_price_with_discount()
        {
            var product = new TestProduct
            {
                Id    = 1,
                Name  = "Product name 1",
                Price = 12.34M,
                CustomerEntersPrice = false,
                Published           = true
            };

            //customer
            var customer = new Customer();

            //discounts
            var discount1 = new Discount
            {
                Id                 = 1,
                Name               = "Discount 1",
                DiscountType       = DiscountType.AssignedToSkus,
                DiscountAmount     = 3,
                DiscountLimitation = DiscountLimitationType.Unlimited
            };

            //discount1.AppliedToProducts.Add(product);
            product.AddAppliedDiscounts(discount1);
            //set HasDiscountsApplied property
            product.HasDiscountsApplied = true;

            _priceCalcService.GetFinalPrice(product, customer).ShouldEqual(9.34M);
        }
Esempio n. 2
0
        public void Can_get_final_product_price_with_discount()
        {
            var product = new TestProduct
            {
                Id    = 1,
                Name  = "Product name 1",
                Price = 12.34M,
                CustomerEntersPrice = false,
                Published           = true
            };

            //customer
            var customer = new Customer();

            //discounts
            var discount1 = new Discount
            {
                Id                 = 1,
                Name               = "Discount 1",
                DiscountType       = DiscountType.AssignedToSkus,
                DiscountAmount     = 3,
                DiscountLimitation = DiscountLimitationType.Unlimited
            };

            //discount1.AppliedToProducts.Add(product);
            product.AddAppliedDiscounts(discount1);
            //set HasDiscountsApplied property
            product.HasDiscountsApplied = true;
            _discountService.Setup(ds => ds.ValidateDiscount(discount1, customer)).Returns(new DiscountValidationResult {
                IsValid = true
            });
            _discountService.Setup(ds => ds.GetAllDiscountsForCaching(DiscountType.AssignedToCategories, null, null, false)).Returns(new List <DiscountForCaching>());
            _discountService.Setup(ds => ds.GetAllDiscountsForCaching(DiscountType.AssignedToManufacturers, null, null, false)).Returns(new List <DiscountForCaching>());

            _priceCalcService.GetFinalPrice(product, customer).ShouldEqual(9.34M);
        }