Companion Inventory Test plan - UQcsse3200/2023-studio-2 GitHub Wiki

Test Plan for CompanionInventoryComponent Class

Initialization Tests

1. Test Constructor with Weapon Type, Ammo, and Max Ammo

  • Create an instance of CompanionInventoryComponent with specific weapon type, ammo count, and max ammo values.
  • Verify that the object is created correctly and that the attributes are set as expected.

2. Test Default Constructor

  • Create an instance of CompanionInventoryComponent using the default constructor.
  • Verify that the object is created with default values and no power-ups.

Weapon and Ammo Management Tests

3. Test getItem Method

  • Create an instance of CompanionInventoryComponent.
  • Use the getItem method to get the current weapon type.
  • Ensure that it returns the correct initial weapon type.

4. Test getAmmo Method

  • Create an instance of CompanionInventoryComponent.
  • Use the getAmmo method to get the current ammo count.
  • Ensure that it returns the correct initial ammo count.

5. Test changeItem Method

  • Create an instance of CompanionInventoryComponent.
  • Use the changeItem method to change the equipped weapon type.
  • Verify that the weapon type is updated correctly.

6. Test changeAmmo Method

  • Create an instance of CompanionInventoryComponent with some initial ammo count.
  • Use the changeAmmo method to add and subtract ammo.
  • Ensure that the ammo count is updated correctly and does not exceed the maximum ammo.

7. Test getMaxAmmo Method

  • Create an instance of CompanionInventoryComponent.
  • Use the getMaxAmmo method to get the maximum ammo.
  • Verify that it returns the correct initial maximum ammo.

Power-up Management Tests

8. Test addPowerup Method

  • Create an instance of CompanionInventoryComponent.
  • Add power-up entities to the inventory using the addPowerup method.
  • Verify that power-ups are added correctly and that the counts are updated.

9. Test useNextPowerup Method

  • Create an instance of CompanionInventoryComponent with some power-ups added.
  • Use the useNextPowerup method to consume the power-ups.
  • Verify that power-ups are used correctly, and the inventory is updated.

10. Test getPowerupCount Method

  • Create an instance of CompanionInventoryComponent with specific power-ups.
  • Use the getPowerupCount method to check the count of each power-up type.
  • Verify that it returns the correct counts.

Weapon Slot Management Tests

11. Test getEquipped Method

  • Create an instance of CompanionInventoryComponent.
  • Use the getEquipped method to get the initially equipped slot.
  • Ensure that it returns the correct initial slot.

12. Test setEquipped Method

  • Create an instance of CompanionInventoryComponent.
  • Use the setEquipped method to change the equipped slot.
  • Verify that the equipped slot is updated correctly.

13. Test changeEquipped Method

  • Create an instance of CompanionInventoryComponent.
  • Use the changeEquipped method to change the equipped slot based on a weapon type.
  • Verify that the equipped slot is updated correctly based on the weapon type.

14. Test getEquippedType Method

  • Create an instance of CompanionInventoryComponent with different weapons equipped in different slots.
  • Use the getEquippedType method to get the type of the currently equipped weapon.
  • Ensure that it returns the correct weapon type.

15. Test GetCurrentAmmo Method

  • Create an instance of CompanionInventoryComponent with different weapons equipped.
  • Use the GetCurrentAmmo method to get the current ammo count for the equipped weapon.
  • Verify that it returns the correct ammo count.

16. Test GetCurrentMaxAmmo Method

  • Create an instance of CompanionInventoryComponent with different weapons equipped.
  • Use the GetCurrentMaxAmmo method to get the maximum ammo for the equipped weapon.
  • Verify that it returns the correct maximum ammo.

17. Test changeEquippedAmmo Method

  • Create an instance of CompanionInventoryComponent with different weapons equipped.
  • Use the changeEquippedAmmo method to change the ammo count for the equipped weapon.
  • Verify that the ammo count is updated correctly.

18. Test getEquippedCooldown Method

  • Create an instance of CompanionInventoryComponent with different weapons equipped.
  • Use the getEquippedCooldown method to get the cooldown for the equipped weapon.
  • Verify that it returns the correct cooldown.

19. Test setEquippedCooldown Method

  • Create an instance of CompanionInventoryComponent with different weapons equipped.
  • Use the setEquippedCooldown method to set the cooldown for the equipped weapon.
  • Verify that the cooldown is updated correctly.

20. Test update Method

  • Create an instance of CompanionInventoryComponent with weapons equipped.
  • Call the update method to decrement cooldowns.
  • Verify that cooldowns are decremented correctly.

21. Test Exception Handling (PowerupComponent Not Found)

  • Create an instance of CompanionInventoryComponent.
  • Attempt to add a power-up entity without a PowerupComponent.
  • Verify that a warning message is logged.