예제 #1
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);
  }
예제 #2
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);
  }
예제 #3
0
  @Test
  public void repair() {

    testingBook.setState(EBookState.DAMAGED);

    assertEquals(testingBook.getState(), EBookState.DAMAGED);
    testingBook.repair();
  }
예제 #4
0
  @Test
  public void testLose() {

    testingBook.setState(EBookState.LOST);

    when(mockLoan.getBook()).thenReturn(testingBook);

    assertEquals(testingBook.getState(), EBookState.LOST);
  }
예제 #5
0
  @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);
  }
예제 #6
0
  @Test
  public void dispose() {
    testingBook.setState(EBookState.DISPOSED);

    assertEquals(testingBook.getState(), EBookState.DISPOSED);
  }