예제 #1
0
  @Test
  public void repair() {

    testingBook.setState(EBookState.DAMAGED);

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

    testingBook.setState(EBookState.LOST);

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

    assertEquals(testingBook.getState(), EBookState.LOST);
  }
예제 #3
0
 @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);
   }
 }
예제 #4
0
 @Test
 public void testCallNumberIsEmpty() {
   try {
     Book callNumberIsEmpty = new Book("Bob Jones", "Subject", "", 4);
     callNumberIsEmpty.getCallNumber();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
예제 #5
0
 @Test
 public void testGetTitleIsEmpty() {
   try {
     Book titleEmpty = new Book("Bob Jones", "", "123456", 4);
     titleEmpty.getTitle();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
예제 #6
0
 @Test
 public void testGetAuthorIsEmpty() {
   try {
     Book authorEmpty = new Book("", "Subject", "123456", 4);
     authorEmpty.getAuthor();
     fail("Illegal Argument Exception");
   } catch (IllegalArgumentException e) {
     assertTrue(true);
   }
 }
예제 #7
0
 @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);
   }
 }
예제 #8
0
 @Test
 public void testRepairBookNotDamaged() {
   testingBook.setState(EBookState.ON_LOAN);
   try {
     testingBook.repair();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #9
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);
  }
예제 #10
0
 @Test
 public void testDisposeBookDamaged() {
   testingBook.setState(EBookState.DAMAGED);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #11
0
 @Test
 public void testDisposeBookLost() {
   testingBook.setState(EBookState.LOST);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #12
0
 @Test
 public void testDisposeBookAvailable() {
   testingBook.setState(EBookState.AVAILABLE);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #13
0
 @Test
 public void testLostBookNotOnLoan() {
   testingBook.setState(EBookState.LOST);
   try {
     testingBook.lose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #14
0
 @Test
 public void testReturnBookNotOnLoan() {
   testingBook.setState(EBookState.DISPOSED);
   try {
     testingBook.returnBook(true);
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
예제 #15
0
  @Test
  public void testBorrowNotAvailable() {
    ILoan loan = null;

    testingBook.setState(EBookState.AVAILABLE);
    try {
      testingBook.borrow(loan);
      fail("Runtime Exception");
    } catch (RuntimeException e) {
      assertTrue(true);
    }
  }
예제 #16
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);
  }
예제 #17
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);
  }
예제 #18
0
 @Test
 public void testGetID() {
   assertEquals(1, BookTesting.getID());
 }
예제 #19
0
 @Test
 public void testGetCallNumber() {
   assertEquals("callNumber", BookTesting.getCallNumber());
 }
예제 #20
0
 @Test
 public void testGetTitle() {
   assertEquals("title", BookTesting.getTitle());
 }
예제 #21
0
 @Test
 public void testGetAuthor() {
   assertEquals("author", BookTesting.getAuthor());
 }
예제 #22
0
  @Test
  public void dispose() {
    testingBook.setState(EBookState.DISPOSED);

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