@Test(expected = RuntimeException.class) public void testLoansConfirmedWrongState() { // Essentially, loansConfirmed cannot be called before it is in state // CONFIRMING_LOANS so simply call loansConfirmed before anything else. assertTrue(!controlClass_.getState().equals(EBorrowState.CONFIRMING_LOANS)); controlClass_.loansConfirmed(); }
@Test public void testLoansConfirmedLoanListCreated() { // We will set up a loan with a member who has no outstanding loans and // then check that the loan was correctly confirmed/committed. controlClass_.initialise(); controlClass_.cardSwiped(1); // Member ID = 1. controlClass_.bookScanned(10); // An available book. controlClass_.scansCompleted(); controlClass_.loansConfirmed(); List<ILoan> loanList = loanDao_.listLoans(); assertEquals(EBorrowState.COMPLETED, controlClass_.getState()); // We know from the setUpTestData method that there are 9 loans, so now // that we have committed this most recent loan, there should be 10. assertEquals(10, loanList.size()); }
@Test public void testLoansConfirmedOneBookBorrowed() { // Initialise, swipe card, scan book, scans complete, loansConfirmed, // then it should pass and be in the desired state. For this one test, // we will ensure that it is in the desired states as it moves through. controlClass_.initialise(); controlClass_.cardSwiped(1); // Member ID = 1. assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState()); controlClass_.bookScanned(10); // An available book. assertEquals(EBorrowState.SCANNING_BOOKS, controlClass_.getState()); controlClass_.scansCompleted(); assertEquals(EBorrowState.CONFIRMING_LOANS, controlClass_.getState()); controlClass_.loansConfirmed(); assertEquals(EBorrowState.COMPLETED, controlClass_.getState()); }