-
Notifications
You must be signed in to change notification settings - Fork 2
Test Plan for OrderActions
Tia Waturuocha edited this page Aug 28, 2024
·
2 revisions
- Framework: JUnit 5
-
Dependencies:
-
OrderActions
: The main class under test. -
ServiceLocator
: Manages the services used in the game. -
DocketService
,InputService
,EventHandler
: Registered services to support the functionality. -
Entity
: A game entity to whichOrderActions
is attached. -
EventListener0
: Mocked event listeners for verifying event triggers.
-
1. Initialisation Test
-
Purpose: Verify that
OrderActions
is properly initialised. -
Setup:
- Initialise
OrderActions
with a reference toGdxGame
. - Register necessary services (
DocketService
,InputService
) in theServiceLocator
. - Attach
OrderActions
to anEntity
. - Simulate the
create()
method call to register listeners and setup the component.
- Initialise
-
Expected Outcome:
- The
OrderActions
component should register listeners for key game events such as"addOrder"
,"removeOrder"
,"reorderDockets"
,"moveOrder"
, and"changeColour"
. - The
OrderActions
should be properly attached to theEntity
.
- The
2. Key Press Handling: Left Bracket Key
- Purpose: Test that pressing the left bracket key triggers the event for shifting dockets to the left.
-
Setup:
- Mock an
EventListener0
for the"shiftDocketsLeft"
event. - Simulate pressing the left bracket key (
Input.Keys.LEFT_BRACKET
) using thekeyDown()
method.
- Mock an
-
Expected Outcome:
- The
keyDown(int keycode)
method should returntrue
for the left bracket key. - The
"shiftDocketsLeft"
event should be triggered, and the associated event listener should handle the event. - No other events (e.g.,
"shiftDocketsRight"
) should be triggered.
- The
3. Key Press Handling: Right Bracket Key
- Purpose: Test that pressing the right bracket key triggers the event for shifting dockets to the right.
-
Setup:
- Mock an
EventListener0
for the"shiftDocketsRight"
event. - Simulate pressing the right bracket key (
Input.Keys.RIGHT_BRACKET
) using thekeyDown()
method.
- Mock an
-
Expected Outcome:
- The
keyDown(int keycode)
method should returntrue
for the right bracket key. - The
"shiftDocketsRight"
event should be triggered, and the associated event listener should handle the event. - No other events (e.g.,
"shiftDocketsLeft"
) should be triggered.
- The
4. Key Press Handling: Unhandled Key
-
Purpose: Ensure that pressing a key not handled by the
OrderActions
component returnsfalse
. -
Setup:
- Simulate pressing an unrelated key (e.g., the
A
key) using thekeyDown()
method.
- Simulate pressing an unrelated key (e.g., the
-
Expected Outcome:
- The
keyDown(int keycode)
method should returnfalse
for any unhandled key. - No events should be triggered.
- The
5. Event Handling: Add Order
-
Purpose: Verify that triggering the
"addOrder"
event logs the correct message and initiates any related actions. -
Setup:
- Manually trigger the
"addOrder"
event usingentity.getEvents().trigger("addOrder")
.
- Manually trigger the
-
Expected Outcome:
- The logger should log
"Add order"
. - The event handling logic associated with adding an order should execute correctly (if applicable).
- The logger should log
6. Event Handling: Remove Order
-
Purpose: Ensure that the
"removeOrder"
event triggers reordering of dockets and logs the correct message. -
Setup:
- Manually trigger the
"removeOrder"
event with an example index usingentity.getEvents().trigger("removeOrder", index)
.
- Manually trigger the
-
Expected Outcome:
- The logger should log
"Remove order"
. - The
"reorderDockets"
event should be triggered with the correct index, ensuring the reordering of dockets.
- The logger should log
7. Event Handling: Move Order
-
Purpose: Verify that the
"moveOrder"
event is handled correctly and logs the appropriate message. -
Setup:
- Manually trigger the
"moveOrder"
event usingentity.getEvents().trigger("moveOrder")
.
- Manually trigger the
-
Expected Outcome:
- The logger should log
"Move order"
. - Any associated logic for moving orders should execute correctly (if applicable).
- The logger should log
8. Event Handling: Change Colour
-
Purpose: Ensure that the
"changeColour"
event triggers the correct actions related to updating the order's appearance based on the recipe timer. -
Setup:
- Manually trigger the
"changeColour"
event usingentity.getEvents().trigger("changeColour")
.
- Manually trigger the
-
Expected Outcome:
- The logger should log
"Move order"
(or a more appropriate message related to colour change). - The logic associated with changing the colour of an order should execute correctly (if applicable).
- The logger should log
- The test plan should include scenarios where no orders or events are present, ensuring that
OrderActions
does not throw exceptions and logs appropriate warnings.
- Ensure that all events are logged correctly using the logger, and these log messages can be used as part of the test assertions where applicable.
Inventory System
Scoring System
Food Recipes
Level System
Player Actions
Ordering System
Stations
Items
Map Design
Customers
Pause Menu
Upgrades
End of Day Display
Day Night Cycle
Moral System
Debug Terminal
Game Interactions Tutorial
Backstory Cutscenes
Entities and Components
Input Handling
Game Screens and Areas
Fire Extinguisher Handler Component
MainGameActions Create Docket Triggers
Main Game Order Button Display
BackstoryCutsceneDisplay Test Plan
Test Plan for MainGameOrderTicketDisplay
Test Plan for MainGameOrderBtnDisplay
Test Plan for DocketLineDisplay
Test plan for RandomComboService
Test plan for SpeedBoostUpgrade
Test plan for DancePartyUpgrade