-
Notifications
You must be signed in to change notification settings - Fork 1
Dialogue Box Service Testing
Both the Dialogue Box and Dialogue Box Service are tested in parallel. This makes sense as in the design process the Dialogue Box Service was made to be the only interface between some method / class and the Dialogue Box.
This class contains unit tests for the DialogueBoxService
class, which manages the display and functionality of dialogue boxes in the game. It ensures that various features of the DialogueBoxService
are working as expected.
Class-level Annotations:
-
@ExtendWith(GameExtension.class)
: Integrates with the game's extension to set up the necessary environment for testing.
Fields:
-
private DialogueBoxService entityChatService;
: Instance of theDialogueBoxService
to be tested. -
private static final Skin SKIN;
: Skin used for rendering UI elements. -
Stage stage;
: Mock stage used for rendering and UI interactions.
Setup:
-
@BeforeEach
: Initialises the necessary services and mocks before each test.
-
hideChatBox
: Verifies that hiding the dialogue box works as intended.-
Checks:
- The dialogue box is initially visible.
- The dialogue box becomes hidden when
hideCurrentOverlay()
is called.
-
Checks:
-
shouldCreateEntityChat
: Ensures that the dialogue box is created and updated correctly with the provided text.-
Checks:
- The dialogue box is created successfully.
- The hints array matches the input text.
-
Checks:
-
testButtonPresses
: Tests the functionality of the forward and backward buttons in the dialogue box.-
Checks:
- The forward button cycles through the hints in the correct order.
- The backward button cycles through the hints in reverse order.
-
Checks:
-
testOptionButtonPresses
: Tests the functionality of the option buttons in the dialogue box.-
Checks:
- Tests if the clicking on the options changes the dialogue box's text into the appropriate ones.
-
Checks:
-
shouldRemoveEntityChat
: Validates that the dialogue box can be properly disposed of.-
Checks:
- The dialogue box is removed when
disposeCurrentOverlay()
is called. - The
currentOverlay
becomesnull
.
- The dialogue box is removed when
-
Checks:
-
illegalDispose
: Tests the behavior of disposing the dialogue box when it has already been disposed.-
Checks:
- Ensures that calling
disposeCurrentOverlay()
on an already disposed dialogue box does not cause errors and results innull
currentOverlay
.
- Ensures that calling
-
Checks:
-
shouldUpdateEntityChat
: Confirms that updating the dialogue box with new text works correctly.-
Checks:
- The dialogue box displays the updated text.
- The hints array reflects the updated text correctly.
-
Checks:
-
buttonsExist
: Checks that the forward and backward buttons exist and are properly initialised.-
Checks:
- The forward and backward buttons are not
null
when the dialogue box is updated with new text.
- The forward and backward buttons are not
-
Checks: