示例#1
0
 /** Test method for {@link library.Library#checkIn(int[])}. */
 @Test
 public void testCheckInManyBooks() {
   openAndGiveBooksToDave();
   Patron dave = library.serve("Dave");
   ArrayList<Book> davesBooks = dave.getBooks();
   assertEquals(3, davesBooks.size());
   Book someBook = davesBooks.get(1); // Can't be sure which book this is
   library.search(someBook.getTitle()).isEmpty();
 }
示例#2
0
 /** Test method for Check out method */
 public void testCheckOutThreeBoooks() {
   // check out three books
   Patron stanley = openAndServeStanley();
   library.search("nder");
   ArrayList<Book> booksCheckedOut2 = library.checkOut(1, 2, 3);
   assertTrue(stanley.getBooks().contains("nder"));
   assertEquals(stanley.getBooks().size(), 3);
   assertEquals(stanley.getBooks(), booksCheckedOut2);
 }
示例#3
0
 /** The number of books you checked in is more than the books you have in check out list */
 @Test
 public void testCheckInMoreBooks() {
   Patron dave = openAndServeDave();
   library.search("Terry Pratchett");
   library.checkOut(1);
   library.checkOut(3);
   library.checkOut(2);
   ArrayList<Book> davesBooks = dave.getBooks();
   assertEquals(library.checkIn(1, 2, 3, 4), null);
   assertEquals(davesBooks.size(), 3);
 }
示例#4
0
 /** Test method for {@link library.Library#checkOut(int[])}. */
 @Test
 public void testCheckOutOneBook() {
   Patron dave = openAndServeDave();
   library.search("Time");
   ArrayList<Book> booksCheckedOut = library.checkOut(1);
   assertTrue(dave.getBooks().contains(time));
   assertEquals(dave.getBooks(), booksCheckedOut);
   // Book shouldn't still be in library
   ArrayList<Book> booksFound = library.search("Time");
   assertTrue(booksFound.isEmpty());
 }
示例#5
0
 /** Test method for {@link library.Library#checkIn(int[])}. */
 @Test
 public void testCheckInOneBook() {
   Patron dave = openAndServeDave();
   ArrayList<Book> foundBooks = library.search("Disappearing Nightly");
   // Checking out a book moves it from the library to the patron
   library.checkOut(1);
   assertTrue(dave.getBooks().contains(nightly));
   assertTrue(library.search("Disappearing Nightly").isEmpty());
   // Checking in a book moves it back from the patron to the library
   library.serve("Dave");
   library.checkIn(1);
   assertFalse(library.search("Disappearing Nightly").isEmpty());
 }
示例#6
0
 /** Test method for {@link library.Library#checkOut(int[])}. */
 @Test
 public void testCheckOutBooksInRandomOrder() {
   Patron dave = openAndServeDave();
   library.search("Terry Pratchett");
   library.checkOut(1);
   library.checkOut(3);
   library.checkOut(2);
   ArrayList<Book> davesBooks = dave.getBooks();
   assertTrue(davesBooks.contains(witches));
   assertTrue(davesBooks.contains(sisters));
   assertTrue(davesBooks.contains(equalRites));
   assertEquals(davesBooks.size(), 3);
 }