コード例 #1
0
 public PromotionRuleEngineTests()
 {
     _mockProductDataAccessService       = new Mock <IProductDataAccessService>();
     _mockPromotionRuleDataAccessService = new Mock <IPromotionRuleDataAccessService>();
     _promotionRuleEngine = new PromotionRuleEngine(_mockProductDataAccessService.Object
                                                    , _mockPromotionRuleDataAccessService.Object);
     _cart = null;
 }
コード例 #2
0
        public void Promotion_WhenNoProducts_PriceIsZero()
        {
            var promotionEngine = new PromotionRuleEngine(GetPromotionPricingRules());
            var products        = new List <string>();

            var totalAmount = promotionEngine.GetTotalAmount(products);

            Assert.AreEqual(0, totalAmount);
        }
コード例 #3
0
        public void Promotion_OneA_OneB_OneC_OneD_Is280()
        {
            var promotionEngine = new PromotionRuleEngine(GetPromotionPricingRules());
            var products        = new List <string>
            {
                "A", "B", "C", "D"
            };
            var totalAmount = promotionEngine.GetTotalAmount(products);

            Assert.AreEqual(115, totalAmount);
        }
コード例 #4
0
        public void Promotion_FiveA_FiveB_OneC_Is370()
        {
            var promotionEngine = new PromotionRuleEngine(GetPromotionPricingRules());
            var products        = new List <string>
            {
                "A", "B", "C", "A", "B", "A", "B", "A", "B", "A", "B"
            };
            var totalAmount = promotionEngine.GetTotalAmount(products);

            Assert.AreEqual(370, totalAmount);
        }
コード例 #5
0
        public void Promotion_ThreeA_ThreeB_Is205()
        {
            var promotionEngine = new PromotionRuleEngine(GetPromotionPricingRules());
            var products        = new List <string>
            {
                "A", "A", "A", "B", "B", "B"
            };
            var totalAmount = promotionEngine.GetTotalAmount(products);

            Assert.AreEqual(205, totalAmount);
        }