Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }