コード例 #1
0
        public void ApplyPromotion_FixedPrice_Test1()
        {
            _cartManager.Add(new Product("A", "Product A", 50.0M), 5);
            _cartManager.Add(new Product("B", "Product B", 30.0M), 5);
            _cartManager.Add(new Product("C", "Product C", 20.0M), 1);
            _cartManager.Add(new Product("D", "Product D", 15.0M), 1);

            var promotionSelector = new Func <ICollection <Promotion>, Promotion>(promotions =>
            {
                //Selecting first available promotion which is 3 A's for 130
                return(promotions.FirstOrDefault());
            });

            Assert.AreEqual(_cartManager.ApplyPromotion(promotionSelector), 130 + 100 + 150 + 35);
        }