Esempio n. 1
0
 public Market(ICommandManager commandManager,
               IProductCart cartManager,
               ICartCouponCommandFactory couponCommandFactory)
 {
     _commandManager       = commandManager ?? throw new ArgumentNullException(nameof(commandManager));
     _couponCommandFactory = couponCommandFactory ?? throw new ArgumentNullException(nameof(couponCommandFactory));
     ProductCart           = cartManager ?? throw new ArgumentNullException(nameof(cartManager));
 }
Esempio n. 2
0
        private static IMarket CreateTestMarket(IProductCart cart)
        {
            var marketCommandManager = new CommandManager();
            var cartCouponCommands   = new CartCouponCommandFactory();

            var market     = new Market(marketCommandManager, cart, cartCouponCommands);
            var cartCoupon = new DiscountCartCoupon(0.2M);

            market.SetCartCoupon(cartCoupon);

            return(market);
        }
Esempio n. 3
0
        private static void FillCart(IProductCart cart)
        {
            var candyProductInfo = new ProductPriceInfo(new Candy("Vanilla", 50, 10, 5));

            candyProductInfo.SetQty(4);

            var productCoupon = new DiscountProductCoupon(0.25M, 3);

            candyProductInfo.SetProductCoupon(productCoupon);

            cart.AddProduct(candyProductInfo);

            var juiceProductInfo = new ProductPriceInfo(new Juice("Orange", 25, 50, "red"));

            juiceProductInfo.SetQty(2);
            cart.AddProduct(juiceProductInfo);
        }
Esempio n. 4
0
 public SetCouponToCartCommand(IProductCart cart, ICartCoupon cartCoupon)
 {
     _cart           = cart;
     _newCoupon      = cartCoupon;
     _previousCoupon = _cart.CartCoupon;
 }
Esempio n. 5
0
 public ICommand CreateSetCartCouponCommand(IProductCart cart, ICartCoupon cartCoupon)
 {
     return(new SetCouponToCartCommand(cart, cartCoupon));
 }