PlateComponent Test Plan - UQcsse3200/2024-studio-3 GitHub Wiki
Overview
The PlateComponentTest class is th unit testing the PlateComponent class, which models a plate entity in the game with various properties such as quantity, item status, and availability. The test cases aim to verify that the component behaves as expected when initialized, manipulated, and interacted with through various operations
Test Case
- PlateComponent Constructor Test
- Objective: Validate that the PlateComponent constructor initializes the component with the correct values for quantity and default params
- Testing Steps:
- Create an instance of PlateComponent with a specified quantity (e.g., 3)
- Assert that the properties quantity, isStacked, id, and plateArray are correctly set
- Expected Result: All assertions should pass, confirming that the constructor correctly initializes the PlateComponent instance
- Add Meal to Plate Test
- Objective: Validate that adding a meal to the plate correctly updates the plat item status, availability, and servability
- Testing Steps:
- Set the plate quantity to 2
- Add a meal (e.g “Steak”) to the plate
- Assert that the item on the plate is correctly set, availability is false, and servability is true
- Expected Result: The item should be correctly added, the plate should not be available, and it should be servable
- Unavailable After Dispose Test
- Objective: Confirm that disposing of the plate makes it unavailable
- Testing Steps:
- Call the dispose method on the PlateComponent
- Assert that the plate is no longer available
- Expected Result: The plate should be marked as unavailable after disposal
- Quantity Initialization Test
- Objective: Verify that the initial quantity of the plate matches the value passed during instantiation
- Testing Steps:
- Check the quantity of the plate after instantiation
- Expected Result: The initial quantity should match the expected value (e.g., 3)
- Set Quantity Test
- Objective: Ensure that setting a new quantity updates the plate quantity correctly
- Testing Steps:
- Set the quantity to a new value (e.g., 5)
- Assert that the plate quantity matches the new value
- Expected Result: The plate quantity should be updated to 5
- Washed State After Instantiation Test
- Objective: Confirm that the plate is in a washed state upon instantiation
- Testing Steps:
- Check the washed status of the plate after instantiation
- Expected Result: The plate should be marked as washe
- Availability After Instantiation Test
- Objective: Validate that the plate is available for use immediately after instantiation
- Testing Steps:
- Check the availability status of the plate
- Expected Result: The plate should be availabl
- Not Servable After Instantiation Test
- Objective: Ensure that the plate is not servable immediately after instantiation
- Testing Steps:
- Check the servability status of the plate
- Expected Result: The plate should not be servable initially
- Set ID Test
- Objective: Confirm that setting the ID of the plate updates the ID correctly
- Testing Steps:
- Set the ID to a specific value (e.g 1)
- Assert that the plate Id matches the given value
- Expected Result: The plate Id should be correctly updated
Test Structure
Setup: Mock Entities are setup prior testing
Assertions: The tests primarily use assertions such as assertEquals, assertTrue, assertFalse, assertNotNull, and assertArrayEquals to validate the expected outcomes
Test Execution
Each test method is constructed to try to maximize the amount of coverage test code being cover.