示例#1
0
 @Test
 public void testKidneyCustomerPay() {
   assertTrue(cashier.customers.isEmpty());
   cashier.msgCustomerDone(waiter, customer, "Steak");
   int funds = cashier.funds;
   assertFalse(cashier.customers.isEmpty());
   assertTrue(cashier.customers.get(0).state == CustomerState.paying);
   cashier.pickAndExecuteAnAction();
   assertTrue(cashier.customers.get(0).state == CustomerState.paid);
   assertTrue(
       waiter
           .log
           .getLastLoggedEvent()
           .getMessage()
           .equalsIgnoreCase(
               "Received message msgHereIsBill from Cashier for Customer "
                   + customer.getName()
                   + " of price 15.99"));
   cashier.msgICantPay(customer);
   assertTrue(cashier.customers.get(0).state == CustomerState.poor);
   cashier.pickAndExecuteAnAction();
   assertTrue(
       customer
           .log
           .getLastLoggedEvent()
           .getMessage()
           .equalsIgnoreCase("Received message removeKidney from cashier"));
   assertTrue(cashier.customers.isEmpty());
 }
示例#2
0
 @Test
 public void testNormalCustomerPay() {
   assertTrue(cashier.customers.isEmpty());
   cashier.msgCustomerDone(waiter, customer, "Steak");
   int funds = cashier.funds;
   assertFalse(cashier.customers.isEmpty());
   assertTrue(cashier.customers.get(0).state == CustomerState.paying);
   cashier.pickAndExecuteAnAction();
   assertTrue(cashier.customers.get(0).state == CustomerState.paid);
   assertTrue(
       waiter
           .log
           .getLastLoggedEvent()
           .getMessage()
           .equalsIgnoreCase(
               "Received message msgHereIsBill from Cashier for Customer "
                   + customer.getName()
                   + " of price 15.99"));
   cashier.msgTakeMyMoney(customer, 20);
   assertTrue(cashier.customers.get(0).state == CustomerState.awaitingChange);
   cashier.pickAndExecuteAnAction();
   assertTrue(
       customer
           .log
           .getLastLoggedEvent()
           .getMessage()
           .equalsIgnoreCase(
               "Received message msgTakeYourChange from Cashier with $4.01 in change"));
   assertTrue(cashier.customers.isEmpty());
 }