public void HandleTestWithException()
        {
            ShoppingCartRepository.ClearCart();
            var productCommandProxy = new ProductCommandProxy();

            var command = new AddQuantityCommand()
            {
                ProductId = 0,
                Quantity  = 5
            };

            productCommandProxy.Store(command);

            command = new AddQuantityCommand()
            {
                ProductId = 0,
                Quantity  = 16
            };

            productCommandProxy.Store(command);

            while (!productCommandProxy.Process())
            {
            }
        }
        public void QuantityAddedDbEventHandlerTest()
        {
            ShoppingCartRepository.ClearCart();

            var quantityAddedEvent = new QuantityAddedEvent()
            {
                AddedQuantity = 5,
                ProductId     = 2
            };

            var quantityAddedDbEventHandler = new QuantityAddedDbEventHandler();

            quantityAddedDbEventHandler.Handle(quantityAddedEvent);

            var repositoryResult = (List <ShoppingCartElement>)ShoppingCartRepository.GetAllShoppingCartElements();

            Assert.AreEqual(repositoryResult.Count, 1);
        }
        public IActionResult Checkout(Order order)
        {
            var items = _shoppingCart.GetShoppingCartItems();

            _shoppingCart.ShoppingCartItems = items;

            if (_shoppingCart.ShoppingCartItems.Count == 0)
            {
                ModelState.AddModelError("", "Your cart is empty, add some teas first");
            }

            if (ModelState.IsValid)
            {
                _orderRepository.CreateOrder(order);
                _shoppingCart.ClearCart();
                return(RedirectToAction("CheckoutComplete"));
            }
            return(View(order));
        }
        public void HandleTest()
        {
            ShoppingCartRepository.ClearCart();
            var productCommandProxy = new ProductCommandProxy();

            var command = new AddQuantityCommand()
            {
                ProductId = 1,
                Quantity  = 5
            };

            productCommandProxy.Store(command);

            command = new AddQuantityCommand()
            {
                ProductId = 2,
                Quantity  = 16
            };

            productCommandProxy.Store(command);

            command = new AddQuantityCommand()
            {
                ProductId = 3,
                Quantity  = 3
            };

            productCommandProxy.Store(command);

            while (!productCommandProxy.Process())
            {
            }

            List <string> shoppingCartQueryResult = (List <string>) new ShoppingCartQuery().GetNamedShoppingCartElements();

            Assert.AreEqual(shoppingCartQueryResult.Count, 3);
        }
Exemple #5
0
 public void Handle(ClearShoppingCartEvent eventData)
 {
     ShoppingCartRepository.ClearCart();
 }