RandomComboService - UQcsse3200/2024-studio-3 GitHub Wiki

Test Environment

  • Framework: JUNIT 5
  • Dependencies:
  • EventHandler: Used to trigger events
  • RandomComboService: Class being tested
  • ServiceLocator: Manages services used throughout
  • Mockito: Used to mock dependencies

Test Cases

1. testGetSelectedUpgrade

  • Purpose: To verify that getSelectedUpgrade() returns one of the upgrades
  • Setup: Initialise RandomComboService with a mocked EventHandler
  • Expected Outcome: Returns a string that matches a valid upgrade

2. testActivateUpgrade

  • Purpose: To verify that activateUpgrade triggers correct event based on selected upgrade
  • Setup:
    • Initialise RandomComboService with a mocked EventHandler
    • Override the getSelectedUpgrade method
  • Expected: The activateUpgrade() method triggers the event with mocked EventHandler

3. testGetEvents

  • Purpose: To verify that getEvents returns the correct EventHandler
  • Setup: Initialise RandomComboService with a mocked EventHandler
  • Expected: Use assertEquals to check if returned instance matches mock provided in setup