Main Game Order Button Display - UQcsse3200/2024-studio-3 GitHub Wiki

Test Environment

  • Framework: JUnit 5
  • Objects Used:
    • MainGameOrderBtnDisplay (under test)
    • RenderService, Stage, DocketService (mocked)
    • Entity, SpriteBatch (mocked)

Test Cases - Testing MainGameOrderBtnDisplay Component Methods

  1. Component Setup
    Purpose: To ensure that the MainGameOrderBtnDisplay component is correctly initialised and registered with required services.
    Expected Results:

    • RenderService and DocketService should be mocked and registered with ServiceLocator.
    • The stage for the button display should be correctly assigned during setup.
  2. Button Creation
    Purpose: To verify that the button display correctly adds UI actors when the addActors() method is called.
    Expected Results:

    • The addActors() method should be called at least once during the test.
  3. Component Association with Entity
    Purpose: To verify that the MainGameOrderBtnDisplay component is correctly associated with an Entity.
    Expected Results:

    • Adding the button display to an entity should allow retrieval of the same entity through getEntity().
  4. Dispose Method Functionality
    Purpose: To ensure that the dispose() method correctly clears UI elements when called.
    Expected Results:

    • Before disposal, the table should contain children elements.
    • After calling dispose(), the table should have no children elements.
  5. Dummy Test for Draw Method
    Purpose: To acknowledge that the draw() method currently performs no meaningful operations.
    Expected Results:

    • The draw() method should run without exceptions or side effects.
  6. Get Z Index
    Purpose: To confirm that the ZIndex of the button display is correctly set.
    Expected Results:

    • getZIndex() should return 2f.
  7. Get and Set State
    Purpose: To verify that the state of the button display can be toggled and retrieved correctly.
    Expected Results:

    • Setting the state to true should return true from getState().
    • Setting the state to false should return false from getState().