-
Notifications
You must be signed in to change notification settings - Fork 4
MapServiceTest
Introduction:
The MapServiceTest
class is devised to validate the functionality of the MapService
class. This service is primarily designed for interaction with and management of the game map. The testing procedure aims to ensure that MapService
accurately retrieves and manages data associated with the terrain, height, and width of the game map.
Objective: The primary objectives of this test plan are:
- To verify that the
MapService
correctly retrieves the associatedTerrainComponent
. - To ensure that
MapService
accurately gets the height and width of the game map.
Methodology:
-
Setup (BeforeEach):
- Mock the core components:
TerrainFactory
,TerrainComponent
, andEntity
. - Set up the behavior for the mocked components using
when()
. This includes linking theTerrainFactory
to create theTerrainComponent
and theEntity
to retrieve theTerrainComponent
.
- Mock the core components:
Test Case: testConstructor
Objective:
To ensure that the MapService
correctly retrieves and stores the TerrainComponent
associated with the given Entity
.
Steps:
-
Service Initialization:
- Instantiate the
MapService
with the mockedEntity
andTerrainFactory
.
- Instantiate the
-
Assertions:
- Confirm that the
TerrainComponent
retrieved fromMapService
matches the mockedTerrainComponent
.
- Confirm that the
Expected Outcome:
The TerrainComponent
stored in MapService
should match the mocked TerrainComponent
.
Test Case: testGetHeight
Objective:
To validate that the MapService
correctly retrieves the height of the game map.
Steps:
-
Mocking Map Bounds:
- Mock the behavior of the
TerrainComponent
to return a specific height when queried for map bounds.
- Mock the behavior of the
-
Service Initialization and Method Invocation:
- Instantiate the
MapService
and invoke itsgetHeight()
method.
- Instantiate the
-
Assertions:
- Verify that the height retrieved matches the height defined in the mocked map bounds.
Expected Outcome:
The height retrieved from MapService
should be 2.
Test Case: testGetWidth
Objective:
To validate that the MapService
correctly retrieves the width of the game map.
Steps:
-
Mocking Map Bounds:
- Mock the behavior of the
TerrainComponent
to return a specific width when queried for map bounds.
- Mock the behavior of the
-
Service Initialization and Method Invocation:
- Instantiate the
MapService
and invoke itsgetWidth()
method.
- Instantiate the
-
Assertions:
- Verify that the width retrieved matches the width defined in the mocked map bounds.
Expected Outcome:
The width retrieved from MapService
should be 5.
Assumptions:
- The core components such as
TerrainFactory
,TerrainComponent
, andEntity
function as expected during interaction withMapService
. - The mocked behaviors defined in the setup are consistent across test cases.
Potential Challenges:
- Change in Terrain Configuration: If there are modifications to the terrain's design or structure, tests may need adjustments.
-
Component Interactions: If the interaction method between
MapService
and other components (likeEntity
orTerrainComponent
) changes, the tests will require updates.