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
-
Component Setup
Purpose: To ensure that theOrderActions
component is properly initialised and registered with required services.
Expected Results:DocketService
andInputService
should be registered with theServiceLocator
.OrderActions
should be correctly added to theEntity
and retrievable throughgetComponent()
.
-
Shift Dockets Left - KeyDown Event
Purpose: To verify that pressing theLEFT_BRACKET
key triggers the "shiftDocketsLeft" event.
Expected Results:- The
keyDown()
method should returntrue
when theLEFT_BRACKET
key is pressed. - The registered event listener for "shiftDocketsLeft" should be invoked.
- The
-
Shift Dockets Right - KeyDown Event
Purpose: To verify that pressing theRIGHT_BRACKET
key triggers the "shiftDocketsRight" event.
Expected Results:- The
keyDown()
method should returntrue
when theRIGHT_BRACKET
key is pressed. - The registered event listener for "shiftDocketsRight" should be invoked.
- The
-
Unhandled Key - KeyDown Event
Purpose: To ensure that thekeyDown()
method returnsfalse
for unhandled keys.
Expected Results:- Pressing the 'A' key should return
false
as it is not a handled key.
- Pressing the 'A' key should return
-
KeyUp Event
Purpose: To confirm that thekeyUp()
method returnsfalse
since it does not perform any operations.
Expected Results:- Calling
keyUp()
with any key (e.g., 'A') should returnfalse
.
- Calling
-
KeyTyped Event
Purpose: To verify that thekeyTyped()
method returnsfalse
since it does not perform any operations.
Expected Results:- Typing any character (e.g., 'A') should return
false
.
- Typing any character (e.g., 'A') should return
-
Logger Initialisation
Purpose: To ensure that the logger forOrderActions
is properly initialised.
Expected Results:- Calling
getLogger()
should return a non-null logger instance.
- Calling