Exemplo n.º 1
0
        public void TestScenario3()
        {
            //1 Arrange
            // setup inputs

            RuleRepository promotionDB = new RuleRepository();

            var lstActivePromotions          = promotionDB.GetActiveRules();
            ProductRepository productContext = new ProductRepository();
            var products = productContext.Products;

            /*
             * Setup unitPrices
             * Set Active Promotions
             * 3 of A's for 130
             * 2 of B's for  45
             * C & D for 30
             *
             * Scenario
             *
             * 3 *A 130
             * 5 * B 45 +45 + 1* 30
             * 1 * C -
             * 1 * D 30
             * Total = 280
             *
             */


            decimal expected = 280;
            decimal actual   = 0;//

            //2 Act

            //  initialize cart

            Cart cart = new Cart();

            // addproducts

            cart.AddProduct(products.First(p => p.SKU == "A"), 3);
            cart.AddProduct(products.First(p => p.SKU == "B"), 5);
            cart.AddProduct(products.First(p => p.SKU == "C"), 1);
            cart.AddProduct(products.First(p => p.SKU == "D"), 1);
            cart.AddPromotions(lstActivePromotions);

            // setup promotions to cart
            // need to introduce a way to handle promotions to Cart and robust Product handling mechanism

            //checkout
            cart.Checkout();

            actual = cart.Total;


            //3 Assert

            Assert.AreEqual(actual, expected);
        }