예제 #1
0
        public void ShoppingCartComments()
        {
            const string file = "shoppingcart-commentedout.txt";
            const int expected = 0;

            var map = new ShoppingListMapper();
            var list = map.ReadShoppingList(file);

            Assert.AreEqual(expected, list.Keys.Count);
        }
예제 #2
0
        public void ShoppingCartAddApples()
        {
            const string file = "shoppingcart-5apples.txt";
            const int expected = 5;

            var map = new ShoppingListMapper();
            var list = map.ReadShoppingList(file);

            Assert.AreEqual(expected, list["apple"]);
        }
 public void Cleanup()
 {
     cartMapper = null;
     ruleMapper = null;
 }
 public void Init()
 {
     cartMapper = new ShoppingListMapper();
     ruleMapper = new PriceRulesMapper();
 }
예제 #5
0
        public void CheckOut()
        {
            var slm = new ShoppingListMapper();
            var prm = new PriceRulesMapper();

            //process the price rules list
            var rules = prm.ReadRules(_priceRulesFile);

            //process the shopping cart
            var items = slm.ReadShoppingList(_cartFile);

            //check to make sure everything purchased has a price
            foreach ( var key in items.Keys)
            {
                if (rules.ContainsKey(key)) continue;

                var rule = prm.GetRuleForMissingItem(key);
                rules[key] = rule;
            }

            this.ProcessReceipt(items, rules, _compoundSavings);
        }