Ejemplo n.º 1
0
        public void CanOnlySaveValidOrders(string name, decimal area, string productType, string state, bool expected)
        {
            Order order = new Order();

            order.CustomerName = name;
            order.Area         = area;
            order.ProductType  = productType;
            order.State        = state;

            OrderValidator    validator = new OrderValidator();
            SaveOrderResponse actual    = validator.SaveOrder(order);

            Assert.AreEqual(expected, actual.EverythingIsAlright);
        }
Ejemplo n.º 2
0
        public void SaveOrdersToFile(List <Order> orders, string filePath)
        {
            SaveOrderResponse[] response = new SaveOrderResponse[orders.Count];

            OrderValidator validator = new OrderValidator();
            int            iterator  = 0;

            foreach (Order o in orders)
            {
                response[iterator] = validator.SaveOrder(o);
                iterator++;
            }

            bool justDandy = true;

            for (int i = 0; i < response.Length; i++)
            {
                if (response[i].EverythingIsAlright)
                {
                    continue;
                }
                else
                {
                    justDandy = false;
                }
            }

            if (justDandy)
            {
                OrderRepository.SaveOrders(orders, filePath);
            }
            else
            {
                throw new Exception("GOD HAS ABANDONED US, THE PROGRAM IS FOR NAUGHT, THE DEVIL HAS TAKEN HUMAN FORM");
            }
        }