Esempio n. 1
0
        public void Run_OnStartup_ShowAllBooks()
        {
            var bookConsole = new BookConsole(_bookRepository, _console);

            _console.ReadLine().Returns(ActionExit.ToString());

            bookConsole.Run();

            _console.Received(1).WriteLine($"0 | {_book.Title} | {(_book.Available ? "Is available" : "Not available")}");
        }
Esempio n. 2
0
        public void Run_WhenUserChooseRemove_CallRemoveBook()
        {
            var bookConsole = new BookConsole(_bookRepository, _console);

            _console.ReadLine().Returns(
                ActionRemove.ToString(),
                0.ToString(),
                ActionExit.ToString());

            bookConsole.Run();

            _bookRepository.Received(1).Remove(Arg.Is <Book>(
                                                   b => b.Id == _book.Id && b.Title == _book.Title && b.Available == _book.Available));
        }
Esempio n. 3
0
        public void Run_WhenUserChooseInsert_CallInsertBook()
        {
            const string NewBookTitle = "New Title";
            var          bookConsole  = new BookConsole(_bookRepository, _console);

            _console.ReadLine().Returns(
                ActionInsert.ToString(),
                NewBookTitle,
                ActionExit.ToString());

            bookConsole.Run();

            _bookRepository.Received(1).Insert(Arg.Is <Book>(b => b.Id == Guid.Empty && b.Title == NewBookTitle));
        }
Esempio n. 4
0
        public void Run_WhenUserChooseUpdate_CallUpdateBook()
        {
            const string NewBookTitle = "New Title";
            var          bookConsole  = new BookConsole(_bookRepository, _console);

            _console.ReadLine().Returns(
                ActionUpdate.ToString(),
                0.ToString(),
                NewBookTitle,
                ActionExit.ToString());

            bookConsole.Run();

            _bookRepository.Received(1).Update(Arg.Is <Book>(
                                                   b => b.Id == _book.Id && b.Title == NewBookTitle && b.Available == _book.Available));
        }