Пример #1
0
        private static void Main(string[] args)
        {
            try
            {
                // -- Categories
                var category1 = new Category("Teknoloji");
                var category2 = new Category("Yiyecek");

                // -- Products
                var product1 = new Product("FANTA", 50.0, category2);
                var product2 = new Product("MABCOOK", 10.0, category1);
                var product3 = new Product("MOUSE", 10.0, category1);
                var product4 = new Product("KEYBOARD", 10.0, category1);

                // -- Additems
                var cart = new ShoppingCartManager();
                cart.AddItem(product1, 10);
                cart.AddItem(product2, 6);
                cart.AddItem(product3, 2);
                cart.AddItem(product4, 3);

                // -- Campaign Discounts
                var campaign1 = new Campaign(product2, 50, 5, DiscountType.Rate);
                //var campaign2 = new Campaign(product2, 20, 5, DiscountType.Amount);
                cart.ApplyDiscounts(campaign1);

                // -- Coupon Discounts
                var coupon1 = new Coupon(100, 500, DiscountType.Amount);
                //var coupon2 = new Coupon(20, 50, DiscountType.Rate);
                cart.ApplyCoupons(coupon1);


                // -- Act
                cart.Print();
                cart.IncreaseItemQty(product2);


                Console.WriteLine(" ");
                Console.WriteLine(" ");

                // -- Act
                cart.Print();

                Console.ReadLine();
            }
            catch (Exception x)
            {
                Console.WriteLine(x.Message);
            }
            finally
            {
                Console.ReadLine();
            }
        }
        public void SetUp()
        {
            _cart         = new Cart();
            _shoppingCart = new ShoppingCartManager(_cart);
            // -- category
            _category1 = new Category("CAR");

            // -- products
            _product1Category1 = new Product("M01", "Motor Yağı", 200.0, _category1);
            _product2Category1 = new Product("C01", "Cam Sileceği", 50.0, _category1);

            // -- add products
            _shoppingCart.AddItem(_product1Category1, 10);
            _shoppingCart.AddItem(_product2Category1, 10);
        }
Пример #3
0
        public void SetUp()
        {
            _cart         = new Cart();;
            _shoppingCart = new ShoppingCartManager(_cart);

            // -- category
            _category2 = new Category("HEALTH");
            _category1 = new Category("CAR");

            // -- product
            _product1Category1 = new Product("MOTOR01", "Motor Yağı", 200.0, _category1);
            _product2Category1 = new Product("SILECEK", "Cam Sileceği", 50.0, _category1);
            _product3Category2 = new Product("BALIKY01", "Balık Yağı", 50.0, _category2);

            // -- add products
            _shoppingCart.AddItem(_product1Category1, 10);
            _shoppingCart.AddItem(_product2Category1, 10);
        }
        public void GetDiscount_Ensure_Campaign_Discount_Applied_Return_True(
            string productName, string productDesc, double productUnitPrice,
            int productQuantity, double discount, DiscountType discountType,
            double minPurchaseAmount, double expectedResult)
        {
            var cart = new Cart();
            // -- create product
            var product = new Product(productName, productDesc, productUnitPrice, _categoryTech);

            _shoppingCart = new ShoppingCartManager(cart);
            _shoppingCart.AddItem(product, productQuantity);

            // -- apply coupon
            var coupon = new Coupon(discount, minPurchaseAmount, discountType);

            cart.CartCoupons.Add(coupon);
            cart.CouponDiscount = new CouponManager(cart).ApplyDiscount();

            Assert.AreEqual(new CouponManager(cart).GetDiscount(), expectedResult);
        }