public void CheckPassTheRules() { this.product_quantity.Add(product1, 1); this.product_quantity.Add(product2, 1); Func <ShoppingBasket, bool> f = new Func <ShoppingBasket, bool>(CheckTotalWeightNoMoreThan400); IRule r = new Rule(f); policyTest.AddRule(r); Assert.IsTrue(policyTest.Check(this.shoppingBasket)); }
public void CheckSomeRulesFalse() { Mock <IRule> rule1 = new Mock <IRule>(); rule1.Setup(r => r.Check(It.IsAny <ShoppingBasket>())).Returns(true); Mock <IRule> rule2 = new Mock <IRule>(); rule2.Setup(r => r.Check(It.IsAny <ShoppingBasket>())).Returns(false); Policy policy = new Policy(); policy.AddRule(rule1.Object); policy.AddRule(rule2.Object); Assert.AreEqual(false, policy.Check(shoppingBasket)); }