@Test public void repair() { testingBook.setState(EBookState.DAMAGED); assertEquals(testingBook.getState(), EBookState.DAMAGED); testingBook.repair(); }
@Test public void testLose() { testingBook.setState(EBookState.LOST); when(mockLoan.getBook()).thenReturn(testingBook); assertEquals(testingBook.getState(), EBookState.LOST); }
@Test public void testBookIdIsNegative() { try { Book idIsNegative = new Book("Bob Jones", "Subject", null, -4); idIsNegative.getID(); fail("Illegal Argument Exception"); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testCallNumberIsEmpty() { try { Book callNumberIsEmpty = new Book("Bob Jones", "Subject", "", 4); callNumberIsEmpty.getCallNumber(); fail("Illegal Argument Exception"); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testGetTitleIsEmpty() { try { Book titleEmpty = new Book("Bob Jones", "", "123456", 4); titleEmpty.getTitle(); fail("Illegal Argument Exception"); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testGetAuthorIsEmpty() { try { Book authorEmpty = new Book("", "Subject", "123456", 4); authorEmpty.getAuthor(); fail("Illegal Argument Exception"); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testBookIdIsZero() { try { Book idIsZero = new Book("Bob Jones", "Subject", "123456", 0); idIsZero.getID(); fail("Illegal Argument Exception"); } catch (IllegalArgumentException e) { assertTrue(true); } }
@Test public void testRepairBookNotDamaged() { testingBook.setState(EBookState.ON_LOAN); try { testingBook.repair(); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testGetLoan() { testingBook.setState(EBookState.ON_LOAN); when(mockLoan.getBook()).thenReturn(testingBook); when(mockLoan.isOverDue()).thenReturn(false); assertEquals(testingBook.getState(), EBookState.ON_LOAN); }
@Test public void testDisposeBookDamaged() { testingBook.setState(EBookState.DAMAGED); try { testingBook.dispose(); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testDisposeBookLost() { testingBook.setState(EBookState.LOST); try { testingBook.dispose(); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testDisposeBookAvailable() { testingBook.setState(EBookState.AVAILABLE); try { testingBook.dispose(); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testLostBookNotOnLoan() { testingBook.setState(EBookState.LOST); try { testingBook.lose(); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testReturnBookNotOnLoan() { testingBook.setState(EBookState.DISPOSED); try { testingBook.returnBook(true); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testBorrowNotAvailable() { ILoan loan = null; testingBook.setState(EBookState.AVAILABLE); try { testingBook.borrow(loan); fail("Runtime Exception"); } catch (RuntimeException e) { assertTrue(true); } }
@Test public void testReturnBookNotDamaged() { testingBook.setState(EBookState.ON_LOAN); when(mockLoan.getBook()).thenReturn(testingBook); assertEquals(testingBook.getState(), EBookState.ON_LOAN); testingBook.returnBook(false); assertEquals(testingBook.getState(), EBookState.AVAILABLE); }
@Test public void testReturnBookDamaged() { testingBook.setState(EBookState.ON_LOAN); when(mockLoan.getBook()).thenReturn(testingBook); assertEquals(testingBook.getState(), EBookState.ON_LOAN); testingBook.returnBook(true); assertEquals(testingBook.getState(), EBookState.DAMAGED); }
@Test public void testGetID() { assertEquals(1, BookTesting.getID()); }
@Test public void testGetCallNumber() { assertEquals("callNumber", BookTesting.getCallNumber()); }
@Test public void testGetTitle() { assertEquals("title", BookTesting.getTitle()); }
@Test public void testGetAuthor() { assertEquals("author", BookTesting.getAuthor()); }
@Test public void dispose() { testingBook.setState(EBookState.DISPOSED); assertEquals(testingBook.getState(), EBookState.DISPOSED); }