Esempio n. 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.");
 }
Esempio n. 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!");
 }
Esempio n. 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.");
 }
Esempio n. 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?");
 }
Esempio n. 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.");
 }
Esempio n. 6
0
 @Test
 public void shouldReportErrorMessageWhenUserSelectsABookThatDoesNotExist() throws IOException {
   when(bufferedReader.readLine()).thenReturn("2", "100", "1", "0");
   when(library.checkOutBook(99)).thenReturn(false);
   when(library.checkOutBook(0)).thenReturn(true);
   bookList.add(harryPotter);
   menu.respondToUserInput(library);
   verify(printStream).println(contains("That book is not available."));
 }
Esempio n. 7
0
  @Test
  public void shouldShowMenuOptionsWhenMenuIsDisplayed() {
    menu.showOptions();
    verify(printStream).println(contains("[1] Show all books"));
    verify(printStream).println(contains("[2] Check out book"));
    verify(printStream).println(contains("[3] Return Book"));
    verify(printStream).println(contains("[4] Show all movies"));
    verify(printStream).println(contains("[5] Check out movies"));

    verify(printStream).println(contains("[0] Quit"));
  }
Esempio n. 8
0
 @Test
 public void shouldBePromptedOnceWhenQuitIsFirstChoice() throws IOException {
   when(bufferedReader.readLine()).thenReturn("0", "1");
   menu.respondToUserInput(library);
   verify(bufferedReader).readLine();
 }
Esempio n. 9
0
 @Test
 public void shouldReportErrorMessageWhenInputIsNotInteger() throws IOException {
   when(bufferedReader.readLine()).thenReturn("not an integer", "1", "0");
   menu.respondToUserInput(library);
   verify(printStream).println(contains("Select a valid option!"));
 }
Esempio n. 10
0
 @Test
 public void shouldReportErrorWhenInvalidIntegerSelected() throws IOException {
   when(bufferedReader.readLine()).thenReturn("-1", "1", "0");
   menu.respondToUserInput(library);
   verify(printStream).println("Select a valid option!");
 }
Esempio n. 11
0
 @Test
 public void shouldListBooksWhenMenuOptionOneIsSelected() throws IOException {
   when(bufferedReader.readLine()).thenReturn("1", "0");
   menu.respondToUserInput(library);
   verify(library).listBooks();
 }
Esempio n. 12
0
 @Test
 public void shouldCallCheckOutFromLibraryWithCorrectMovie() throws IOException {
   when(bufferedReader.readLine()).thenReturn("5", "1", "0");
   menu.respondToUserInput(library);
   verify(library).checkOutMovie(0);
 }
Esempio n. 13
0
 @Test
 public void shouldListBooksWhenCustomerWantsToCheckOutABook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(library).listBooks();
 }
Esempio n. 14
0
 @Test
 public void shouldTellUserWhenTheyHaveSuccessfullyCheckedOutABook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(printStream).println(contains("Thank you! Enjoy the book"));
 }
Esempio n. 15
0
 @Test
 public void shouldPromptUserToPickBookWhenUserWantsToCheckOutBook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(printStream).println("Which book would you like to check out?");
 }
Esempio n. 16
0
 @Test
 public void shouldListMoviesWhenFourIsChosen() throws IOException {
   when(bufferedReader.readLine()).thenReturn("4", "0");
   menu.respondToUserInput(library);
   verify(library).listMovies();
 }
Esempio n. 17
0
 @Test
 public void shouldPromptUserToPickMovieWhenUserWantsToCheckOutMovie() throws IOException {
   when(bufferedReader.readLine()).thenReturn("5", "0");
   menu.respondToUserInput(library);
   verify(printStream).println("Which movie would you like to check out?");
 }
Esempio n. 18
0
 @Test
 public void shouldLogInUserWhenCustomerSelectsOption6() throws IOException {
   when(bufferedReader.readLine()).thenReturn("6", "0");
   menu.respondToUserInput(library);
   verify(library).logInUser();
 }
Esempio n. 19
0
 @Test
 public void shouldListMoviesWhenCustomerWantsToCheckOutAMovie() throws IOException {
   when(bufferedReader.readLine()).thenReturn("5", "0");
   menu.respondToUserInput(library);
   verify(library).listMovies();
 }
Esempio n. 20
0
 @Test
 public void shouldCallCheckOutFromLibraryWithCorrectBook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(library).checkOutBook(0);
 }