@Test public void shouldPromptUserWhenFailedReturnBook() throws IOException { when(bufferedReader.readLine()).thenReturn("3", "1"); when(library.returnBook(anyString())).thenReturn(false, true); menu.respondToUserInput(library); verify(printStream).println("That is not a valid book to return."); }
@Test public void shouldCallReturnToLibraryWithCorrectBook() throws IOException { when(bufferedReader.readLine()).thenReturn("3", "SOME BOOK TITLE!", "0"); when(library.returnBook(anyString())).thenReturn(true); menu.respondToUserInput(library); verify(library).returnBook("SOME BOOK TITLE!"); }
@Test public void shouldThankUserWhenSuccessfulReturnOfBook() throws IOException { when(bufferedReader.readLine()).thenReturn("3", "1"); when(library.returnBook(anyString())).thenReturn(true); menu.respondToUserInput(library); verify(printStream).println("Thank you for returning the book."); }
@Test public void shouldPromptUserForBookTitleTheyWantToReturn() throws IOException { when(bufferedReader.readLine()).thenReturn("3", "SOME TITLE!", "0"); when(library.returnBook(anyString())).thenReturn(true); menu.respondToUserInput(library); verify(printStream).println("Which book would you like to return?"); }
@Test public void shouldAllowUserToReenterReturningBookTitle() throws IOException { when(bufferedReader.readLine()).thenReturn("3", "1"); when(library.returnBook(anyString())).thenReturn(false, true); menu.respondToUserInput(library); verify(printStream).println("That is not a valid book to return."); verify(printStream).println("Thank you for returning the book."); }