|
|
|
@ -20,7 +20,7 @@ public class OrderTest { |
|
|
|
private static final double DELTA = 0.01; |
|
|
|
|
|
|
|
/** |
|
|
|
* Some standard menu items to be used in tests. TODO add more if needed |
|
|
|
* Some standard menu items to be used in tests. |
|
|
|
*/ |
|
|
|
private static final MenuItem[] MENU_ITEMS = { |
|
|
|
new MenuItem("Steak", 25.45, MenuItemType.ENTREE), |
|
|
|
@ -73,6 +73,20 @@ public class OrderTest { |
|
|
|
assertEquals(97645, order2.getOrderNumber()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Tests the Order(Order) const |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
public void testOrderOrder() { |
|
|
|
Order o1 = new Order(order1); |
|
|
|
assertTrue(checkOrder(o1, 531, new MenuItem[] { MENU_ITEMS[0], |
|
|
|
MENU_ITEMS[8], MENU_ITEMS[14] })); |
|
|
|
|
|
|
|
Order o2 = new Order(order2); |
|
|
|
assertTrue(checkOrder(o2, 97645, new MenuItem[] { MENU_ITEMS[3], |
|
|
|
MENU_ITEMS[6], MENU_ITEMS[11], MENU_ITEMS[12] })); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Test the {@link Order#getItemCount()} method |
|
|
|
*/ |
|
|
|
@ -249,6 +263,36 @@ public class OrderTest { |
|
|
|
assertNotEquals("25% Tip missing", -1, order2Str.indexOf("6.40")); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Tests the substitute item method |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
public void testSubstituteItem() { |
|
|
|
MenuItem[] items1 = { MENU_ITEMS[3], |
|
|
|
// item 6 with name changed |
|
|
|
new MenuItem("Boiling Water", 3.50, MenuItemType.DRINK), |
|
|
|
MENU_ITEMS[11], MENU_ITEMS[12] }; |
|
|
|
|
|
|
|
// Should substitute Water |
|
|
|
// do this after creating the array of menu items |
|
|
|
assertTrue("Wrong value returned", |
|
|
|
order2.substituteItem(MENU_ITEMS[6], "Boiling Water")); |
|
|
|
|
|
|
|
assertTrue("SubstituteItem failed", checkOrder(order2, 97645, items1)); |
|
|
|
|
|
|
|
// Since it has already been replaced, the type & cost will match, but |
|
|
|
// not the name, therefore returning false. |
|
|
|
assertFalse("Wrong value returned", |
|
|
|
order2.substituteItem(MENU_ITEMS[6], "Boiling Water")); |
|
|
|
|
|
|
|
// Since it has already been replaced, the Name & Cost will match, but |
|
|
|
// not the type, therefore returning false. |
|
|
|
assertFalse("Wrong value returned", |
|
|
|
order2.substituteItem( |
|
|
|
new MenuItem("Boiling Water", 3.50, MenuItemType.SOUP), |
|
|
|
"Chicken Noodle")); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Compares two MenuItems |
|
|
|
* |
|
|
|
|