@Test public void getItemsInRoom() throws Exception { // setup Room getItemsInRoom = new Room("test"); DirtyDiaper diaperInRoom = new DirtyDiaper("somekid"); DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2"); getItemsInRoom.addItem(diaperInRoom); getItemsInRoom.addItem(diaperInRoom2); ArrayList listOfItemsInRoom = getItemsInRoom.getItemsInRoom(); // does the diaper exist in the room? assertTrue(listOfItemsInRoom.contains(diaperInRoom)); assertTrue(listOfItemsInRoom.contains(diaperInRoom2)); }
@Test public void testClearItems() { // setup Room testRemoveItem = new Room("test"); DirtyDiaper diaperInRoom = new DirtyDiaper("somekid"); DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2"); testRemoveItem.addItem(diaperInRoom); testRemoveItem.addItem(diaperInRoom2); ArrayList listOfItemsInRoom = testRemoveItem.getItemsInRoom(); // does the diaper exist in the room right now? assertTrue(listOfItemsInRoom.contains(diaperInRoom)); assertTrue(listOfItemsInRoom.contains(diaperInRoom2)); testRemoveItem.clearItems(listOfItemsInRoom); // is the list empty? assertTrue(listOfItemsInRoom.isEmpty()); }
@Test public void testRemoveItem() throws Exception { // setup Room testRemoveItem = new Room("test"); DirtyDiaper diaperInRoom = new DirtyDiaper("somekid"); DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2"); testRemoveItem.addItem(diaperInRoom); testRemoveItem.addItem(diaperInRoom2); ArrayList listOfItemsInRoom = testRemoveItem.getItemsInRoom(); // does the diaper exist in the room right now? assertTrue(listOfItemsInRoom.contains(diaperInRoom)); assertTrue(listOfItemsInRoom.contains(diaperInRoom2)); // remove items from the room testRemoveItem.removeItem(diaperInRoom2); // does diaperInRoom2 exist in the room now? assertFalse(listOfItemsInRoom.contains(diaperInRoom2)); }