Test Plan for Customer Sensor Component - UQcsse3200/2024-studio-3 GitHub Wiki
Test Environment
- Framework: JUnit 4
- _Objects Used: CustomerSensorComponent, InteractionComponent, Entity (mocked), CustomerComponent (mocked), Non-Customer Entity (mocked)
Test Cases - Testing CustomerSensorComponent Methods
-
Customer Sensor Component Initialisation
Purpose: To verify that the CustomerSensorComponent is properly initialised and its interaction component is correctly set up. Expected Results: CustomerSensorComponent, its InteractionComponent, and its fixture should not be null after creation. The fixture should be the same as the entity's created fixture. -
Entity Initialisation Purpose: To verify that the entity is correctly initialised with the InteractionComponent and that its fixture is properly configured. Expected Results: The fixture for the InteractionComponent should not be null. The fixture should be a part of the PLAYER physics layer.
-
Update Docket Textures Purpose: To verify that the Docket updates its textures correctly based on the remaining recipe time. Expected Results: When paused, the texture should not change regardless of time updates. When resumed, the texture should update appropriately based on the remaining time: Remaining time = 1.5s → First texture. Remaining time = 0.3s → Second texture. Remaining time = 1s, total recipe time = 10s → Third texture. Remaining time < 0 → Final texture.
-
Set and Get Recipe Time Purpose: To verify that the recipe time is correctly set and retrieved. Expected Results: Before colliding with a customer, the closest customer object should be null. After colliding with a customer within range, there should be one value inside the collidingFixtures variable.
-
Detecting Closest Customer Purpose: To verify that the closest customer is returned when calling getClosestCustomer(). Expected Results: After colliding with a customer, the closest customer object should not be null. The closest customer object should be the one that is physically closest to the player.
-
Not Detecting Distant Customers Purpose: To verify that customers out of range are not added to the list and cannot be interacted with. Expected Results: After colliding with a customer who is out of range, the closest customer object should remain null.
-
Not Detecting Non-Customer Entities Purpose: To ensure that only customer entities are detected and non-customer entities (e.g., other game objects or NPCs not marked as customers) are ignored by the sensor. Expected Results: After colliding with a non-customer entity, the closest customer object should remain null.
-
Removing a Customer After Collision Ends Purpose: To verify that after the player moves out of range of a customer, the customer is removed from the list of colliding fixtures, and the player can no longer interact with them. Expected Results: After moving out of range of a previously detected customer, the closest customer object should be null.
-
Handling Multiple Customers Purpose: To verify that when multiple customers are within range, the closest customer is always correctly identified and returned by the CustomerSensorComponent. Expected Results: After colliding with multiple customers, the closest customer object should always be the one closest to the player. Moving closer to a different customer should update the closest customer object accordingly.