Order Actions - UQcsse3200/2024-studio-3 GitHub Wiki

Test Environment

  • Framework: JUnit 5
  • Objects Used:
    • OrderActions (under test)
    • DocketService, InputService, Entity (mocked)
    • EventListener0, Logger (mocked)

Test Cases - Testing OrderActions Component Methods

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

    • DocketService and InputService should be registered with the ServiceLocator.
    • OrderActions should be correctly added to the Entity and retrievable through getComponent().
  2. Shift Dockets Left - KeyDown Event
    Purpose: To verify that pressing the LEFT_BRACKET key triggers the "shiftDocketsLeft" event.
    Expected Results:

    • The keyDown() method should return true when the LEFT_BRACKET key is pressed.
    • The registered event listener for "shiftDocketsLeft" should be invoked.
  3. Shift Dockets Right - KeyDown Event
    Purpose: To verify that pressing the RIGHT_BRACKET key triggers the "shiftDocketsRight" event.
    Expected Results:

    • The keyDown() method should return true when the RIGHT_BRACKET key is pressed.
    • The registered event listener for "shiftDocketsRight" should be invoked.
  4. Unhandled Key - KeyDown Event
    Purpose: To ensure that the keyDown() method returns false for unhandled keys.
    Expected Results:

    • Pressing the 'A' key should return false as it is not a handled key.
  5. KeyUp Event
    Purpose: To confirm that the keyUp() method returns false since it does not perform any operations.
    Expected Results:

    • Calling keyUp() with any key (e.g., 'A') should return false.
  6. KeyTyped Event
    Purpose: To verify that the keyTyped() method returns false since it does not perform any operations.
    Expected Results:

    • Typing any character (e.g., 'A') should return false.
  7. Logger Initialisation
    Purpose: To ensure that the logger for OrderActions is properly initialised.
    Expected Results:

    • Calling getLogger() should return a non-null logger instance.