コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Toy Block Factory.");
            var consoleInputOutput = new ConsoleInputOutput();
            var toyBlockFactory    = new ToyBlockFactory(consoleInputOutput);

            toyBlockFactory.StartOrder();

            Console.WriteLine("What would you like to do now?");
            Console.WriteLine("1. Create a new order.");
            Console.WriteLine("2. Create a cutting report.");
            Console.WriteLine("3. Create a painting report.");
            Console.WriteLine("4. Create an invoice.");

            var selection = int.Parse(Console.ReadLine());

            switch (selection)
            {
            case 1:
                toyBlockFactory.StartOrder();
                break;

            case 2:
            {
                Console.WriteLine("Please input the order number you'd like to see the cutting report for: ");
                var orderNumber = int.Parse(Console.ReadLine());
                PrintCuttingReport(toyBlockFactory, orderNumber);
                break;
            }

            case 3:
            {
                Console.WriteLine("Please input the order number you'd like to see the painting report for: ");
                var orderNumber = int.Parse(Console.ReadLine());
                PrintPaintingReport(toyBlockFactory, orderNumber);
                break;
            }

            case 4:
            {
                Console.WriteLine("Please input the order number you'd like to see the invoice report for: ");
                var orderNumber = int.Parse(Console.ReadLine());
                PrintInvoiceReport(toyBlockFactory, orderNumber);
                break;
            }
            }
        }
コード例 #2
0
        public void OrderStatusProcessedWhenBlocksAdded()
        {
            var cashierInput = new CashierInput(new List <int>()
            {
                0, 0, 0, 1, 1, 1, 1, 1, 1
            });
            var toyBlockFactory = new KataToyBlockFactory.ToyBlockFactory(cashierInput);

            toyBlockFactory.StartOrder();
            Assert.Equal(OrderStatus.Processed, toyBlockFactory.GetOrderStatus(1));
        }
コード例 #3
0
        public void OrderStatusNoneWhenNoBlocksAdded()
        {
            var cashierInput = new CashierInput(new List <int>()
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0
            });
            var toyBlockFactory = new KataToyBlockFactory.ToyBlockFactory(cashierInput);

            toyBlockFactory.StartOrder();
            Assert.Equal(OrderStatus.None, toyBlockFactory.GetOrderStatus(1));
        }
コード例 #4
0
        public void CreateOrderFromInput()
        {
            var cashierInput = new CashierInput(new List <int>()
            {
                1, 1, 1, 1, 1, 1, 1, 1, 1
            });
            var toyBlockFactory = new KataToyBlockFactory.ToyBlockFactory(cashierInput);

            toyBlockFactory.StartOrder();
            var cuttingReport = toyBlockFactory.GetCuttingReport(1);

            Assert.Equal(3, cuttingReport.GetShapeTotal(Shape.Circle));
        }
コード例 #5
0
        public void CreateOrderFromInputIncludingZeroQuantity()
        {
            var cashierInput = new CashierInput(new List <int>()
            {
                0, 0, 0, 1, 1, 1, 1, 1, 1
            });

            var toyBlockFactory = new KataToyBlockFactory.ToyBlockFactory(cashierInput);

            toyBlockFactory.StartOrder();
            var cuttingReport = toyBlockFactory.GetCuttingReport(1);

            Assert.Equal(0, cuttingReport.GetShapeTotal(Shape.Square));
        }