Testing Plan for ConcreteRangedWeapon - UQcsse3200/2024-studio-1 GitHub Wiki
Test Plan: ConcreteRangedWeapon class
Introduction
This test plan is designed to validate the functionality of the ConcreteRangedWeapon class, which represents a ranged weapon in the game. The test cases will cover the creation of the weapon, its interaction with other game entities, and its behavior during gameplay, such as pickup, drop, and shooting.
Test Cases
1. Test Weapon Creation
Objective:
Verify that a ConcreteRangedWeapon object can be successfully created and is an instance of RangedWeapon.
Input:
- Weapon name: "gun"
 - Icon path: "gun.png"
 - Damage: 10
 - Range: 10
 - Fire rate: 10
 - Reload time: 10
 - Clip size: 10
 - Ammo: 10
 
Expected Output:
- The created object should be an instance of 
RangedWeapon. 
2. Test Set Weapon Entity
Objective:
Ensure that the weapon entity can be set correctly in a ConcreteRangedWeapon object.
Input:
- Weapon name: "gun"
 - Weapon entity: A mock entity object
 
Expected Output:
- The 
getWeaponEntity()method should return the entity that was set. 
3. Test Get Weapon Entity
Objective:
Check that the correct weapon entity is returned after being set.
Input:
- Weapon entity: A mock entity object
 
Expected Output:
- The entity returned by 
getWeaponEntity()should match the input entity. 
4. Test Weapon Pickup
Objective:
Verify that the pickup() method correctly adds the ranged weapon to the player's inventory.
Input:
- A new 
ConcreteRangedWeaponobject - A player entity with an empty inventory
 
Expected Output:
- The weapon should be added to the player's inventory, and 
inventory.getRanged()should return a present value. 
5. Test Weapon Drop
Objective:
Ensure that the drop() method correctly removes the ranged weapon from the player's inventory.
Input:
- A new 
ConcreteRangedWeaponobject - A player entity with the weapon already picked up
 
Expected Output:
- The weapon should be removed from the player's inventory, and 
inventory.getRanged()should return an empty value. 
6. Test Get Specification
Objective:
Check if the getSpecification() method returns the correct weapon specification string.
Input:
- A 
ConcreteRangedWeaponobject with name "gun" 
Expected Output:
- The method should return "ranged:gun".
 
7. Test Get Weapon Name
Objective:
Ensure that the getName() method returns the correct weapon name.
Input:
- A 
ConcreteRangedWeaponobject with name "gun" 
Expected Output:
- The method should return "gun".
 
8. Test Getters and Setters
Objective:
Verify that the getters and setters for weapon properties (damage, range, fireRate, reloadTime, clipSize, ammo) work as expected.
Input:
- A 
ConcreteRangedWeaponobject with initial values for weapon properties (10 for each) - Update values: 20 for each property
 
Expected Output:
- Getters should return the initial values after creation.
 - Getters should return the updated values after setters are called.
 
9. Test Weapon Shooting
Objective:
Check if the shoot() method fires the weapon correctly and reduces the ammo count appropriately.
Input:
- A 
ConcreteRangedWeaponobject with ammo - A target vector (Vector2.Zero)
 
Expected Output:
- The 
shoot()method should reduce the ammo count and ensure the weapon is still in the player's inventory. 
Conclusion
This test plan covers the core functionality of the ConcreteRangedWeapon class. The test cases ensure that weapon creation, inventory interactions, property modifications, and combat mechanics behave as expected. By passing these tests, the integrity and performance of ranged weapon functionality in the game can be assured.