Test Plan for StationInventoryComponent - UQcsse3200/2024-studio-3 GitHub Wiki

Test Environment

  • Framework: JUnit 4
  • *Objects Used: StationItemHandlerComponent, StationInventoryComponent (mocked), Entity (mocked), EventHandler (mocked)

Test Cases - Testing StationItemHandlerComponent Methods

  1. Getting the Type of the Handler Purpose: To verify that the handler correctly returns its type. Test methods: testGetType() Expected outcome: The getType() method should return "oven" as the type of the handler.
  2. Checking if an Item is Accepted Purpose: To verify that the handler correctly identifies whether an item is acceptable. Test methods: testIsItemAccepted() Expected outcome: The isItemAccepted("meat") method should return true for accepted items like "meat", and false for items like "stone" that are not accepted.
  3. Checking if an Item is Present in the Station - When Item is Present Purpose: To verify that the handler correctly reports the presence of an item in the station's inventory. Test methods: testHasItem_whenItemIsPresent() Expected outcome: When the mocked inventory indicates an item is present, hasItem() should return true.
  4. Checking if an Item is Present in the Station - When Item is Not Present Purpose: To verify that the handler correctly reports the absence of an item in the station's inventory. Test methods: testHasItem_whenItemIsNotPresent() Expected outcome: When the mocked inventory indicates no item is present, hasItem() should return false.
  5. Giving an Item to the Station - When Station is Empty and Item is Accepted Purpose: To verify that an item is correctly added to the station's inventory when the station is empty and the item is accepted. Test methods: testGiveItem_whenStationIsEmptyAndItemAccepted() Expected outcome: If the station is empty, giveItem("meat") should trigger setCurrentItem("meat") in the mocked inventory.
  6. Giving an Item to the Station - When Station is Not Empty Purpose: To verify that no action is taken when attempting to add an item to a full station. Test methods: testGiveItem_whenStationIsNotEmpty() Expected outcome: If the station is not empty, giveItem("meat") should not trigger any changes in the mocked inventory (setCurrentItem() should not be called).
  7. Giving an Item to the Station - When Item is Not Accepted Purpose: To verify that no action is taken when attempting to add an unaccepted item to the station. Test methods: testGiveItem_whenItemNotAccepted() Expected outcome: If the item is not accepted (e.g., "stone"), giveItem("stone") should not trigger any changes in the mocked inventory (setCurrentItem() should not be called).
  8. Taking an Item from the Station - When Item is Present Purpose: To verify that the handler correctly removes an item from the station's inventory when an item is present. Test methods: testTakeItem_whenItemIsPresent() Expected outcome: If an item is present, takeItem() should trigger removeCurrentItem() in the mocked inventory.
  9. Taking an Item from the Station - When Item is Not Present Purpose: To verify that the handler correctly handles the absence of an item in the station's inventory when attempting to take an item. Test methods: testTakeItem_whenItemIsNotPresent() Expected outcome: If no item is present, takeItem() should trigger removeCurrentItem() in the mocked inventory, but it should return an empty result.