예제 #1
0
 @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.");
 }
예제 #2
0
 @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!");
 }
예제 #3
0
 @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.");
 }
예제 #4
0
 @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?");
 }
예제 #5
0
 @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.");
 }