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);
            }
        }
 public void Biblotica_When_Book_Is_Checkedout_Should_Not_Be_In_Available_Books()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("a","a",1990,"ISBN190")});
     biblotica.Checkout ("ISBN190");
     List<Book> books =  biblotica.GetBookList ();
     Assert.AreEqual (0, books.Count );
 }
 public void CheckoutCommand_Should_Incdicate_Success_Message_On_Success()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("A","a",1990,"ISBN1990")});
     CheckoutCommand command = new CheckoutCommand (biblotica,"ISBN1990");
     CommandResult result = command.Execute ();
     Book checkedoutBook = result.Data as Book;
     Assert.AreEqual ("ISBN1990", checkedoutBook.Id);
 }
 public void List_Command_Should_List_The_Books_In_Library()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("A","a",1990,"ISBN1990")});
     ListCommand command = new ListCommand (biblotica);
     CommandResult result = command.Execute ();
     List<Book> books = result.Data as List<Book>;
     Assert.AreEqual (1,books.Count);
     Assert.AreEqual ("[Book: Name=A, Author=a, Year=1990]", books.First().ToString());
 }
 public void CheckoutCommand_Should_Write_Success_Message_To_View()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("A","a",1990,"ISBN1990")});
     CheckoutCommand command = new CheckoutCommand (biblotica,"ISBN1990");
     command.Execute ();
     MockView view = new MockView ("Thank you! Enjoy the book");
     command.WriteResultDataToView (view);
     view.Verify();
 }
 public void CheckoutCommand_Should_Incdicate_Failure_Message_To_View()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("A","a",1990,"ISBN1990")});
     CheckoutCommand command = new CheckoutCommand (biblotica,"ISBN19900");
     command.Execute ();
     MockView view = new MockView ("That book is not available.");
     command.WriteResultDataToView (view);
     view.Verify();
 }
 public CheckoutCommand(Biblotica biblotica, string ISBNNumber)
 {
     _biblotica = biblotica;
     _ISBNNumber = ISBNNumber;
 }
 public ListCommand(Biblotica biblotica)
 {
     _biblotica = biblotica;
 }
 public void Setup()
 {
     _biblotica = new Biblotica (new List<Book>());
 }
 public InputParser(Biblotica biblotica)
 {
     _biblotica = biblotica;
 }
 public void Biblotica_When_Requested_For_BooksList_Should_Contain_Books()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("a","a",1990,"ISBN190")});
     List<Book> books =  biblotica.GetBookList ();
     Assert.AreEqual (1, books.Count );
 }
 public void Biblotica_When_A_NonAvailable_Book_Is_Checkedout_Should_Return_Null()
 {
     Biblotica biblotica = new Biblotica (new List<Book>(){new Book("a","a",1990,"ISBN190")});
     Book actual = biblotica.Checkout ("ISBN1900");
     Assert.IsNull (actual);
 }