Exemplo n.º 1
0
  @Test
  public void repair() {

    testingBook.setState(EBookState.DAMAGED);

    assertEquals(testingBook.getState(), EBookState.DAMAGED);
    testingBook.repair();
  }
Exemplo n.º 2
0
  @Test
  public void testLose() {

    testingBook.setState(EBookState.LOST);

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

    assertEquals(testingBook.getState(), EBookState.LOST);
  }
Exemplo n.º 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);
   }
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 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);
   }
 }
Exemplo n.º 8
0
 @Test
 public void testRepairBookNotDamaged() {
   testingBook.setState(EBookState.ON_LOAN);
   try {
     testingBook.repair();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemplo n.º 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);
  }
Exemplo n.º 10
0
 @Test
 public void testDisposeBookDamaged() {
   testingBook.setState(EBookState.DAMAGED);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemplo n.º 11
0
 @Test
 public void testDisposeBookLost() {
   testingBook.setState(EBookState.LOST);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemplo n.º 12
0
 @Test
 public void testDisposeBookAvailable() {
   testingBook.setState(EBookState.AVAILABLE);
   try {
     testingBook.dispose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemplo n.º 13
0
 @Test
 public void testLostBookNotOnLoan() {
   testingBook.setState(EBookState.LOST);
   try {
     testingBook.lose();
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemplo n.º 14
0
 @Test
 public void testReturnBookNotOnLoan() {
   testingBook.setState(EBookState.DISPOSED);
   try {
     testingBook.returnBook(true);
     fail("Runtime Exception");
   } catch (RuntimeException e) {
     assertTrue(true);
   }
 }
Exemplo n.º 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);
    }
  }
Exemplo n.º 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);
  }
Exemplo n.º 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);
  }
Exemplo n.º 18
0
 @Test
 public void testGetID() {
   assertEquals(1, BookTesting.getID());
 }
Exemplo n.º 19
0
 @Test
 public void testGetCallNumber() {
   assertEquals("callNumber", BookTesting.getCallNumber());
 }
Exemplo n.º 20
0
 @Test
 public void testGetTitle() {
   assertEquals("title", BookTesting.getTitle());
 }
Exemplo n.º 21
0
 @Test
 public void testGetAuthor() {
   assertEquals("author", BookTesting.getAuthor());
 }
Exemplo n.º 22
0
  @Test
  public void dispose() {
    testingBook.setState(EBookState.DISPOSED);

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