Example #1
0
        public void AddOrderLine_OrderLineIsAddedToSalesOrder_SaveIsCalled()
        {
            var salesOrder = new SalesOrder();
            var orderLine = new OrderLine { SalesOrder = salesOrder };

            _uut.AddOrderLine(orderLine);

            _dalFacade.UnitOfWork.Received(1).Save();
        }
Example #2
0
        public void AddOrderLine_OrderLineIsAddedToSalesOrder_SalesOrderRepositoryUpdateIsCalledOnce()
        {
            var salesOrder = new SalesOrder();
            var orderLine = new OrderLine {SalesOrder = salesOrder};

            _uut.AddOrderLine(orderLine);

            _dalFacade.UnitOfWork.SalesOrderRepository.Received(1).Update(Arg.Is(salesOrder));
        }
Example #3
0
 /// <summary>
 /// Inserts an OrderLine into the database.
 /// </summary>
 /// <param name="line">The OrderLine to be inserted</param>
 public virtual void AddOrderLine(OrderLine line)
 {
     using (var uow = _dalFacade.UnitOfWork)
     {
         uow.SalesOrderRepository.Update(line.SalesOrder);
         uow.OrderLineRepository.Insert(line);
         uow.Save();
     }
 }
Example #4
0
        public void ClearOrder_OrderlinesAreClearedFromSalesOrder_SalesOrderRepositoryUpdateIsCalledOnce()
        {
            var salesOrder = new SalesOrder();
            var orderLine = new OrderLine();
            salesOrder.Lines.Add(orderLine);

            _uut.ClearOrder(salesOrder);

            _dalFacade.UnitOfWork.SalesOrderRepository.Received(1).Update(Arg.Is(salesOrder));
        }
        public void CreateReceipt_GenerateReceiptFromASalesOrderWithOneOrderlines_ReceiptContainsEightStrings()
        {
            var orderline = new OrderLine()
            {
                Id = 1,
                Product = new Product("Øl", 18, true),
                Quantity = 2
            };

            var salesorder = new SalesOrder()
            {
                Id = 1,
                Date = new DateTime(2010, 10, 3, 12, 0, 0),
                Status = OrderStatus.Completed
            };

            salesorder.Lines.Add(orderline);

            _uut.CreateReceipt(salesorder);

            _printer.Received(1).Print();
        }
Example #6
0
        public void ClearOrder_OrderlinesAreClearedFromSalesOrder_SaveIsCalledOnce()
        {
            var salesOrder = new SalesOrder();
            var orderLine = new OrderLine();
            salesOrder.Lines.Add(orderLine);

            _uut.ClearOrder(salesOrder);

            _dalFacade.UnitOfWork.Received(1).Save();
        }
Example #7
0
        /// <summary>
        /// Adds an amount of products to the current order.
        /// </summary>
        /// <param name="product">Product to be added to the SalesOrder.</param>
        /// <param name="quantity">The quantity of the product. Can be negative.</param>
        /// <param name="discount">The discount on the product. Can be null.</param>
        public void AddProduct(Product product, int quantity, Discount discount)
        {
            var orderLine = new OrderLine
            {
                SalesOrder = CurrentOrder,
                Product = product,
                Quantity = quantity,
                Discount = discount,
                UnitPrice = product.Price,
                DiscountValue = (discount == null ? 0 : discount.Percent / 100 * product.Price)
            };

            OrderDao.AddOrderLine(orderLine);
            OnPropertyChanged(nameof(CurrentOrder));
        }