예제 #1
0
        public GroceryItemRule GetPricingRule(string ruleText)
        {
            GroceryItemRule rule;

            if (ruleText.Contains("get")) //covers get one for
                rule = new BuyOneGetOneRule(ruleText);
            else if (ruleText.Contains("for")) //covers for $2.00
                rule = new GroupRule(ruleText);
            else
                rule = new PercentOffRule(ruleText);

            return rule;
        }
예제 #2
0
        public void TestingGroupDiscount()
        {
            const string rule = "three apples for $2.5";

            const decimal expected = 0.50m;

            var gRule = new GroupRule(rule);
            var saved = gRule.ProcessAmountSaved(4, 1);

            Assert.AreEqual(expected, saved);
        }