예제 #1
0
        public void ByWeightLineItemWithCouponDiscountHasCorrectPriceTest()
        {
            // Arrange
            // pricePerKilo = 5.00m
            ILineItem     byWeightLineItem1 = new ByWeightLineItem(1, 2.00);
            ILineItem     byWeightLineItem2 = new ByWeightLineItem(1, 8.00);
            const decimal expectedPrice1    = 10.00m;
            const decimal expectedPrice2    = 25.00m;

            // Does not qualify for discount since price < discount
            CouponDiscountLineItem couponDiscountLineItem1 = new CouponDiscountLineItem(byWeightLineItem1)
            {
                CouponDiscount = 15.00m
            };

            // Qualifies for discount since price > discount
            CouponDiscountLineItem couponDiscountLineItem2 = new CouponDiscountLineItem(byWeightLineItem2)
            {
                CouponDiscount = 15.00m
            };

            // Act
            decimal actualPrice1 = couponDiscountLineItem1.GetPrice();
            decimal actualPrice2 = couponDiscountLineItem2.GetPrice();

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(actualPrice1, Is.EqualTo(expectedPrice1));
                Assert.That(actualPrice2, Is.EqualTo(expectedPrice2));
            });
        }
예제 #2
0
        public void FixedPriceLineItemWithCouponDiscountHasCorrectPriceTest()
        {
            // Arrange
            // unitPrice = 10.00m
            ILineItem     fixedPriceLineItem1 = new FixedPriceLineItem(1); // quantity defaults to 1
            ILineItem     fixedPriceLineItem2 = new FixedPriceLineItem(1, 4);
            const decimal expectedPrice1      = 10.00m;
            const decimal expectedPrice2      = 25.00m;

            // Does not qualify for discount since price < discount
            CouponDiscountLineItem couponDiscountLineItem1 = new CouponDiscountLineItem(fixedPriceLineItem1)
            {
                CouponDiscount = 15.00m
            };

            // Qualifies for discount since price > discount
            CouponDiscountLineItem couponDiscountLineItem2 = new CouponDiscountLineItem(fixedPriceLineItem2)
            {
                CouponDiscount = 15.00m
            };

            // Act
            decimal actualPrice1 = couponDiscountLineItem1.GetPrice();
            decimal actualPrice2 = couponDiscountLineItem2.GetPrice();

            // Assert
            Assert.Multiple(() =>
            {
                Assert.That(actualPrice1, Is.EqualTo(expectedPrice1));
                Assert.That(actualPrice2, Is.EqualTo(expectedPrice2));
            });
        }
예제 #3
0
        public void DoubleDiscountedLineItemHasCorrectPriceTest()
        {
            // Arrange
            // unitPrice = 10.00m
            ILineItem     fixedPriceLineItem = new FixedPriceLineItem(1, 3);
            const decimal expectedPrice      = 22.00m;

            BulkDiscountLineItem bulkDiscountLineItem = new BulkDiscountLineItem(fixedPriceLineItem)
            {
                DiscountThreshold  = 20.00m,
                DiscountPercentage = 10
            };

            CouponDiscountLineItem couponDiscountLineItem = new CouponDiscountLineItem(bulkDiscountLineItem)
            {
                CouponDiscount = 5.00m
            };

            // Act
            decimal actualPrice = couponDiscountLineItem.GetPrice();

            // Assert
            Assert.That(actualPrice, Is.EqualTo(expectedPrice));
        }