コード例 #1
0
ファイル: PromotionFacts.cs プロジェクト: dragosv/GroceryCo
        public void AdditionalPromotion_NoMultiple_ShouldNotApply()
        {
            var order = new Order(new [] { new Item(firstProduct) });

            var additionalPromotion = new AdditionalPromotion {
                Category = "fruit", Percent = 50
            };

            Assert.Equal(0, additionalPromotion.ApplyTo(order).Count);
        }
コード例 #2
0
ファイル: PromotionFacts.cs プロジェクト: dragosv/GroceryCo
        public void AdditionalPromotion_AdditionalProducts_ShouldApply()
        {
            var order = new Order(new [] { new Item(firstProduct), new Item(secondProduct) });

            var additionalPromotion = new AdditionalPromotion {
                Category = "fruit", Percent = 50
            };

            var discounts = additionalPromotion.ApplyTo(order);

            Assert.Equal(1, discounts.Count);
            Assert.Equal(order.Items[1], discounts[0].Item);
            Assert.Equal(secondProduct.Price / 2, discounts[0].Value);
        }