Exemple #1
0
        public void OrderManagerAddOrderTest(DateTime date, string customerName, string state, string productType, decimal area, bool expectedResult, int expectedCount)

        {
            TestOrderRepository   testOrderRepo   = new TestOrderRepository();
            TestProductRepository testProductRepo = new TestProductRepository();
            TestTaxRepository     testTaxRepo     = new TestTaxRepository();
            OrderManager          addOrderRule    = new OrderManager(testOrderRepo, testProductRepo, testTaxRepo);
            AddOrderResponse      response        = addOrderRule.BuildNewOrder(date, customerName, state, productType, area);

            //Order order = new Order();

            //order.Date = date;
            //order.OrderNumber = orderNumber;
            //order.CustomerName = customerName;
            //order.State = state;
            //order.TaxRate = taxRate;
            //order.ProductType = productType;
            //order.Area = area;
            //order.CostPerSquareFoot = costPerSqFt;
            //order.LaborCostPerSquareFoot = laborCostPerSqFt;

            Assert.AreEqual(expectedResult, response.Success);
            if (response.Success)
            {
                testOrderRepo.CommitThisOrder(response.Order);

                Assert.AreEqual(expectedCount, testOrderRepo.GetAllOrdersForDate(date).Count);
            }
        }
Exemple #2
0
        internal void Execute()
        {
            OrderManager manager = OrderManagerFactory.Create();

            //AddOrderResponse response = manager.BuildNewOrder(userDate, customerName, state, productType, area);

            Console.Clear();
            Console.WriteLine("Add an Order");
            Console.WriteLine("------------------------------------");
            DateTime userDate = ConsoleIO.GetDateFromUser();

            manager.CreateOrderDate(userDate);
            string         customerName = ConsoleIO.GetNameFromUser();
            string         state        = ConsoleIO.GetStateFromUser();
            List <Product> products     = manager.GetAllProducts();

            ConsoleIO.DisplayProductsToUser(products);
            string  productType = ConsoleIO.GetProductFromUser();
            decimal area        = ConsoleIO.GetAreaFromUser();

            AddOrderResponse response = manager.BuildNewOrder(userDate, customerName, state, productType, area);

            if (!response.Success)
            {
                Console.WriteLine(response.Message);
                Console.WriteLine("Press any key to continue...");
                Console.ReadKey();
            }
            else
            {
                ConsoleIO.DisplayOrderSummary(response.Order);
                Console.ReadKey();
                if (!ConsoleIO.ConfirmOrderPlacement())
                {
                    ConsoleIO.OrderCancelledMessage();
                }
                else
                {
                    manager.CommitOrder(response.Order);
                    ConsoleIO.OrderPlacedMessage();
                }
            }
        }