Exemplo n.º 1
0
  @Test
  public void testRoom() throws Exception {
    // check default values
    Room r1 = new Room("test");
    assertEquals(r1.getNorth(), null);
    assertEquals(r1.getSouth(), null);
    assertEquals(r1.getEast(), null);
    assertEquals(r1.getWest(), null);

    // check if array list is empty
    assertTrue(r1.getItemsInRoom().isEmpty());
  }
Exemplo n.º 2
0
  @Test
  public void testAddItem() throws Exception {
    // setup
    Room testAddItem = new Room("test");
    DirtyDiaper diaperInRoom = new DirtyDiaper("somekid");
    DirtyDiaper diaperInRoom2 = new DirtyDiaper("somekid2");
    testAddItem.addItem(diaperInRoom);
    ArrayList listOfItemsInRoom = testAddItem.getItemsInRoom();

    // does the diaper exist in the room?
    assertTrue(listOfItemsInRoom.contains(diaperInRoom));
  }
Exemplo n.º 3
0
  @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());
  }
Exemplo n.º 4
0
  @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));
  }