示例#1
0
        public void TotalCostTest_promotionAvailable_returnsPromotionCostCalculation() {
            LineItem lineItem = new LineItem(new Item("Apple"));
            lineItem.PricePerUnit = 1.5;
            lineItem.Quantity = 2;

            Promotion promotion = new QuantityPricePromotion(new Item("Apple"), "[email protected]");
            lineItem.Promotion = promotion;
            
            Assert.AreEqual(promotion.GetPromotionAdjustedTotalCost(lineItem), lineItem.TotalCost);
        }
 public void QuantityPricePromotionConstructorTest_validFormula_returnsValidPromotion() {
     QuantityPricePromotion promotion = new QuantityPricePromotion(GetTestItem(), "[email protected]");
     Assert.AreEqual(3, promotion.MinimumNumberItemsForPromotion);
     Assert.AreEqual(1.0, promotion.PromotionPrice);
 }
 public void GetPromotionAdjustedTotalCostTest_withMoreThanSetAmount_returnsPromotionCostAndRegularCost() {
     Item item = GetTestItem();
     LineItem lineItem = GetTestLineItem(item, 4, 3.00);
     QuantityPricePromotion promotion = new QuantityPricePromotion(item, "[email protected]");
     double expectedCost = 1.00 + lineItem.PricePerUnit;
     Assert.AreEqual(expectedCost, promotion.GetPromotionAdjustedTotalCost(lineItem));
 }
 public void GetPromotionAdjustedTotalCostTest_withNullLineItem_returnsZero() {
     QuantityPricePromotion promotion = new QuantityPricePromotion(GetTestItem(), "[email protected]");
     Assert.AreEqual(0, promotion.GetPromotionAdjustedTotalCost(null));
 }
 public void GetPromotionAdjustedTotalCostTest_withEqualToSetAmount_returnsPromotionCost() {
     Item item = GetTestItem();
     LineItem lineItem = GetTestLineItem(item, 3, 3.00);
     QuantityPricePromotion promotion = new QuantityPricePromotion(item, "[email protected]");
     double expectedCost = 1.00;
     Assert.AreEqual(expectedCost, promotion.GetPromotionAdjustedTotalCost(lineItem));
 }