Пример #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.");
 }
Пример #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."));
 }
Пример #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"));
  }
Пример #8
0
 @Test
 public void shouldBePromptedOnceWhenQuitIsFirstChoice() throws IOException {
   when(bufferedReader.readLine()).thenReturn("0", "1");
   menu.respondToUserInput(library);
   verify(bufferedReader).readLine();
 }
Пример #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!"));
 }
Пример #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!");
 }
Пример #11
0
 @Test
 public void shouldListBooksWhenMenuOptionOneIsSelected() throws IOException {
   when(bufferedReader.readLine()).thenReturn("1", "0");
   menu.respondToUserInput(library);
   verify(library).listBooks();
 }
Пример #12
0
 @Test
 public void shouldCallCheckOutFromLibraryWithCorrectMovie() throws IOException {
   when(bufferedReader.readLine()).thenReturn("5", "1", "0");
   menu.respondToUserInput(library);
   verify(library).checkOutMovie(0);
 }
Пример #13
0
 @Test
 public void shouldListBooksWhenCustomerWantsToCheckOutABook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(library).listBooks();
 }
Пример #14
0
 @Test
 public void shouldTellUserWhenTheyHaveSuccessfullyCheckedOutABook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(printStream).println(contains("Thank you! Enjoy the book"));
 }
Пример #15
0
 @Test
 public void shouldPromptUserToPickBookWhenUserWantsToCheckOutBook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(printStream).println("Which book would you like to check out?");
 }
Пример #16
0
 @Test
 public void shouldListMoviesWhenFourIsChosen() throws IOException {
   when(bufferedReader.readLine()).thenReturn("4", "0");
   menu.respondToUserInput(library);
   verify(library).listMovies();
 }
Пример #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?");
 }
Пример #18
0
 @Test
 public void shouldLogInUserWhenCustomerSelectsOption6() throws IOException {
   when(bufferedReader.readLine()).thenReturn("6", "0");
   menu.respondToUserInput(library);
   verify(library).logInUser();
 }
Пример #19
0
 @Test
 public void shouldListMoviesWhenCustomerWantsToCheckOutAMovie() throws IOException {
   when(bufferedReader.readLine()).thenReturn("5", "0");
   menu.respondToUserInput(library);
   verify(library).listMovies();
 }
Пример #20
0
 @Test
 public void shouldCallCheckOutFromLibraryWithCorrectBook() throws IOException {
   successfullyReturnBook();
   menu.respondToUserInput(library);
   verify(library).checkOutBook(0);
 }