예제 #1
0
 @Test
 public void testReturnBookNotOnLoan() {
   testingBook.setState(EBookState.DISPOSED);
   try {
     testingBook.returnBook(true);
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #2
0
  @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);
  }
예제 #3
0
  @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);
  }