Example #1
0
        public void Add_Book_Rule()
        {
            Payment payment = new Payment
            {
                PaymentType = PaymentType.PhysicalProduct,
                ProductName = "Harry Potter Book",
                IsBook      = true
            };
            IRule rule = new Rule_Book();

            ruleManager.AddRule(rule);
            var  ruleResult        = ruleManager.ExecuteRules(payment);
            bool isBookRuleApplied = ruleResult.Contains("Packaging Slip for Royalty Department");

            Assert.IsTrue(isBookRuleApplied);
        }
Example #2
0
        public void Add_Book_And_Physical_Rule()
        {
            Payment payment = new Payment
            {
                PaymentType = PaymentType.PhysicalProduct,
                ProductName = "Harry Potter Book",
                IsBook      = true
            };
            IRule rule = new Rule_Book();

            ruleManager.AddRule(rule);
            // Both rule so that both rules will be added to rule result;
            rule = new Rule_PhysicalProduct();
            ruleManager.AddRule(rule);
            var  ruleResult        = ruleManager.ExecuteRules(payment);
            bool isBookRuleApplied = ruleResult.Contains("Packing Slip for Royalty Department");

            Assert.IsTrue(isBookRuleApplied);
            bool isPhysicalRuleApplied = ruleResult.Contains("Generate Packing Slip");

            Assert.IsTrue(isPhysicalRuleApplied);
        }