Ejemplo n.º 1
0
        public void InputParser_Should_Parse_Input_To_Generate_Checkout_Commad()
        {
            InputParser parser = new InputParser (_biblotica);
            ICommand command = parser.Parse ("checkout 123");

            Assert.IsInstanceOf<CheckoutCommand> (command);
        }
Ejemplo n.º 2
0
        public void InputParser_Should_Parse_Input_To_Generate_exit_Commad()
        {
            InputParser parser = new InputParser (_biblotica);
            ICommand command = parser.Parse ("exit");

            Assert.IsInstanceOf<ExitCommand> (command);
        }
Ejemplo n.º 3
0
        public Application()
        {
            List<Book> books = new List<Book> ();
            books.Add(new Book ("Object Thinking","Dr.David West",1990,"ISBN1990"));
            books.Add(new Book ("Cakes, Puddings + Category Theory","a",2015,"ISBN2015"));
            Biblotica app = new Biblotica (books);
            InputParser parser = new InputParser (app);
            _shouldContinue = true;
            ConsoleView view = new ConsoleView ();
            InitCommand startCommand = new InitCommand ();
            startCommand.Execute ();
            startCommand.WriteResultDataToView (view);

            while(_shouldContinue)
            {
                Console.WriteLine ("Input:");
                string input = Console.ReadLine ();
                ICommand command = parser.Parse (input);
                if (command is ExitCommand) {
                    _shouldContinue = false;
                }
                command.Execute();
                command.WriteResultDataToView(view);
            }
        }