@Test public void testWarnsUserIfNoBooksAreAvailable() { when(library.numberOfBooksInLibrary()).thenReturn(0); checkoutBookMenuOperation.execute(library, console); verify(console).printMessage("There are no books available for checkout"); }
@Test public void testInvalidCheckoutBookOptionDoesNotRemoveBookFromList() { String commands[] = {"193738"}; setUserInput(commands); checkoutBookMenuOperation.execute(library, console); verify(library, never()).checkOutBook(193738); }
@Test public void testInvalidCheckoutBookOptionWarnsUser() { String commands[] = {"-23"}; setUserInput(commands); checkoutBookMenuOperation.execute(library, console); verify(console).printMessage("That book is not available"); }
@Test public void testValidCheckoutBookOptionGivesUserThankYouMessage() { String commands[] = {"1"}; setUserInput(commands); checkoutBookMenuOperation.execute(library, console); verify(console).printMessage("Thank you! Enjoy the book"); }
@Test public void testValidCheckoutBookOptionRemovesBookFromList() { String commands[] = {"1"}; setUserInput(commands); checkoutBookMenuOperation.execute(library, console); verify(library).checkOutBook(1); }
@Test public void testUserPromptedForBookSelectionOnExecute() { checkoutBookMenuOperation.execute(library, console); verify(console).printMessage("> Enter book number: "); }
@Test public void testAvailableBookListPrintedOnExecute() { checkoutBookMenuOperation.execute(library, console); verify(console).printLibraryItemList(library.availableBooks()); }
@Test public void testCheckoutBooksHeaderPrintedOnExecute() { checkoutBookMenuOperation.execute(library, console); verify(console).printMessage("Books available for checkout:"); }
@Test public void testCheckoutBookIsTriggeredByUpperCaseC() { assertTrue(checkoutBookMenuOperation.isTriggeredBy("C")); }
@Test public void testUserNeedsToBeLoggedIn() { assertTrue(checkoutBookMenuOperation.needsLogin()); }