示例#1
0
 @Override
 public void doOperation() {
   console.display("Enter return book title: ");
   String booktitle = console.getUserInput();
   Book book = new Book(booktitle, "UNKNOWN_AUTHOR", UNKNOWN_YEAR);
   String returnMessage = library.returnBook(book, user);
   console.display(returnMessage);
 }
  @Test
  public void shouldCheckOutUnsuccessfullyFromLibraryIfBookNotExists() {
    when(console.getUserInput()).thenReturn("Head");

    checkOutOption.doOperation();

    verify(console).display("That book is not available\n");
  }
  @Test
  public void shouldCheckOutBookSuccessfullyFromLibraryIfBookExists() {
    when(console.getUserInput()).thenReturn("Head First Java");

    checkOutOption.doOperation();

    verify(console).display("Thank you ! Enjoy the book\n");
  }
  @Test
  public void shouldAskForBookTitle() {
    when(console.getUserInput()).thenReturn("Head First Java");

    checkOutOption.doOperation();

    verify(console).display("Enter booktitle to checkout: ");
  }
示例#5
0
 private String getUserLibraryNumber(Console console) {
   console.show(INPUT_YOUR_LIBRARY_NUMBER);
   return console.getUserInput();
 }
示例#6
0
 private String getUserInputPassword(Console console) {
   console.show(INPUT_YOUR_PASSWORD);
   return console.getUserInput();
 }