public void CheckAndDiscountsAddedRulesFalse() { ConditionDiscount discount = new ConditionDiscount(discountCalc1.Object); Mock <IRule> rule1 = new Mock <IRule>(); rule1.Setup(r => r.Check(It.IsAny <ShoppingBasket>())).Returns(true); discount.AddRule(rule1.Object); Mock <IRule> rule2 = new Mock <IRule>(); rule2.Setup(r => r.Check(It.IsAny <ShoppingBasket>())).Returns(false); ConditionDiscount addedDiscount = discount.And(rule2.Object); Assert.AreEqual(0, addedDiscount.ApplyDiscounts(shoppingBasket).Discount); }
public void CheckXorDiscountsBothFalse() { ConditionDiscount discount1 = new ConditionDiscount(discountCalc1.Object); ConditionDiscount discount2 = new ConditionDiscount(discountCalc2.Object); Mock <IRule> rule1 = new Mock <IRule>(); rule1.Setup(r => r.Check(It.IsAny <ShoppingBasket>())).Returns(false); discount1.AddRule(rule1.Object); Mock <IRule> rule2 = new Mock <IRule>(); rule2.Setup(r => r.Check(It.IsAny <ShoppingBasket>())).Returns(false); discount2.AddRule(rule2.Object); ConditionDiscount xorDiscount = discount1.Xor(discount2, true); Assert.AreEqual(0, xorDiscount.ApplyDiscounts(shoppingBasket).Discount); }
public void CheckApplyDiscounts() { ConditionDiscount discount = new ConditionDiscount(discountCalc1.Object); Assert.AreEqual(15, discount.ApplyDiscounts(shoppingBasket).Discount); }