Exemplo n.º 1
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));
        }
Exemplo n.º 2
0
        public void AddOrderLine_OrderLineIsAddedToSalesOrder_SaveIsCalled()
        {
            var salesOrder = new SalesOrder();
            var orderLine = new OrderLine { SalesOrder = salesOrder };

            _uut.AddOrderLine(orderLine);

            _dalFacade.UnitOfWork.Received(1).Save();
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
0
        public void CreateReceipt_GenerateReceiptFromASalesOrderWithNoOrderlines_ReceiptContainsSevenStrings()
        {
            var salesorder = new SalesOrder()
            {
                Id = 1,
                Date = new DateTime(2010, 10, 3, 12, 0, 0),
                Status = OrderStatus.Completed
            };

            _uut.CreateReceipt(salesorder);

            _printer.Received(1).Print();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Formats a new Reciept from an order and prints the Reciept.
        /// </summary>
        /// <param name="order">The Order to be formatted and printed.</param>
        public virtual void CreateReceipt(SalesOrder order)
        {
            var receipt = new Receipt(_formatProvider);

            CreateHeader(receipt, order.Id);

            foreach (var p in order.Lines)
            {
                receipt.AddLine(string.Format(_formatProvider, "{0}x\t{1}\n", p.Quantity, p.Product.Name));
                receipt.AddLine("              ");
                receipt.AddLine(string.Format(_formatProvider, "{0}\n\n", p.UnitPrice));
            }

            receipt.AddLine(string.Format(_formatProvider, "Total: {0}\n\n", order.Total));

            CreateFooter(receipt);

            Print(receipt);
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
 public void Delete_SalesOrderIsDeleted_SalesOrderRepositoryDeleteIsCalledOnce()
 {
     var salesOrder = new SalesOrder();
     _uut.Delete(salesOrder);
     _dalFacade.UnitOfWork.SalesOrderRepository.Received(1).Delete(Arg.Is(salesOrder));
 }
Exemplo n.º 8
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();
        }
Exemplo n.º 9
0
 public void Update_SalesOrderIsUpdated_SaveIsCalledOnce()
 {
     var salesOrder = new SalesOrder();
     _uut.Update(salesOrder);
     _dalFacade.UnitOfWork.Received(1).Save();
 }
Exemplo n.º 10
0
        public void SetUp()
        {
            _salesOrderOne = new SalesOrder { Id = 1 };
            var salesOrderTwo = new SalesOrder { Id = 2 };
            _salesOrderThree = new SalesOrder { Id = 3 };
            var salesOrders = new List<SalesOrder> { salesOrderTwo, _salesOrderOne, _salesOrderThree };

            _dalFacade = Substitute.For<IDalFacade>();
            _dalFacade.UnitOfWork.SalesOrderRepository
                .When(x => x.Get(null, Arg.Any<Func<IQueryable<SalesOrder>, IOrderedQueryable<SalesOrder>>>()))
                .Do(x => _orderedSalesOrders = x.Arg<Func<IQueryable<SalesOrder>, IOrderedQueryable<SalesOrder>>>().Invoke(salesOrders.AsQueryable()).ToList());
            _dalFacade.UnitOfWork.SalesOrderRepository
                .Get(null, Arg.Any<Func<IQueryable<SalesOrder>, IOrderedQueryable<SalesOrder>>>())
                .Returns(salesOrders);

            _uut = new OrderDao(_dalFacade);
        }
Exemplo n.º 11
0
 public void Insert_SalesOrderIsInserted_SaveIsCalledOnce()
 {
     var salesOrder = new SalesOrder();
     _uut.Insert(salesOrder);
     _dalFacade.UnitOfWork.Received(1).Save();
 }
Exemplo n.º 12
0
 public void Insert_SalesOrderIsInserted_SalesOrderRepositoryInsertIsCalledOnce()
 {
     var salesOrder = new SalesOrder();
     _uut.Insert(salesOrder);
     _dalFacade.UnitOfWork.SalesOrderRepository.Received(1).Insert(Arg.Is(salesOrder));
 }
Exemplo n.º 13
0
        private static void Main(string[] args)
        {
            _logger = LogFactory.GetLogger(typeof (Program));

            IDatabaseInitializer<CashRegisterContext> seed;

            // Empty
            // seed = new EmptyInitializer();

            // Kalle Seed
            //seed = new CashProductInitializer();

            // Lærke Seed
            seed = new FullProductInitializer();

            using (var contex = new CashRegisterContext(seed))
            {
                Console.WriteLine("FLAF");
                contex.Database.Initialize(true);
                contex.SaveChanges();
            }

            IDalFacade dalFacade = new DalFacade();
            IProductDao pd = new ProductDao(dalFacade);
            IProductController pc = new ProductController(pd);

            SalesOrder o;

            using (var uow = dalFacade.UnitOfWork)
            {
                var d = new Discount
                {
                    Description = "Discount",
                    Percent = 0,
                };
                uow.DiscountRepository.Insert(d);
                uow.Save();

                o = new SalesOrder
                {
                    Date = DateTime.Now,
                    Status = OrderStatus.Created,
                };
                uow.SalesOrderRepository.Insert(o);

            }
            using (var uow = dalFacade.UnitOfWork)
            {

                var t = new Transaction
                {
                    Date = DateTime.Now,
                    Description = "Flaf",
                    PaymentType = PaymentType.Cash,
                    Price = 20,
                    SalesOrder = o,
                    Status = TransactionStatus.Created
                };
                uow.TransactionRepository.Insert(t);
                uow.Save();
            }

                Console.WriteLine("ProductTabs");
            foreach (var productTab in pc.ProductTabs)
            {
                Console.WriteLine(productTab.Priority + ": " + productTab.Name);
                foreach (var productType in productTab.ProductTypes)
                {
                    Console.WriteLine("\t" + productType.Name);
                    foreach (var productGroup in productType.ProductGroups)
                    {
                        Console.WriteLine("\t\t" + productGroup.Name);
                        foreach (var product in productGroup.Products)
                        {
                            Console.WriteLine("\t\t\t" + product.Name);
                        }
                    }
                }
            }

            _logger.Fatal("Fatal");
            _logger.Err("Error");
            _logger.Warn("Warn");
            _logger.Info("Info");
            _logger.Debug("Debug");
        }
Exemplo n.º 14
0
 /// <summary>
 /// Creates a new SalesOrder and inserts it into the database.
 /// </summary>
 private void CreateNewOrder()
 {
     CurrentOrder = new SalesOrder
     {
         Status = OrderStatus.Created,
         Date = DateTime.Now,
     };
     OrderDao.Insert(CurrentOrder);
     OnPropertyChanged(nameof(CurrentOrder));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Clears the orderlines from an excisting SalesOrder.
 /// </summary>
 /// <param name="order">The SalesOrder to be cleared.</param>
 public void ClearOrder(SalesOrder order)
 {
     using (var uow = _dalFacade.UnitOfWork)
     {
         uow.SalesOrderRepository.Update(order);
         foreach (var orderLine in order.Lines.ToList())
         {
             order.Lines.Remove(orderLine);
             uow.OrderLineRepository.Delete(orderLine);
         }
         uow.Save();
     }
 }
Exemplo n.º 16
0
 /// <summary>
 /// Update a SalesOrder in the database.
 /// </summary>
 /// <param name="order">The SalesOrder to be updated.</param>
 public virtual void Update(SalesOrder order)
 {
     using (var uow = _dalFacade.UnitOfWork)
     {
         uow.SalesOrderRepository.Update(order);
         uow.Save();
     }
 }