bis
Some checks failed
Create tag and build when new code gets to main / BumpTag (push) Successful in 20s
Create tag and build when new code gets to main / Export (push) Successful in 6m8s
Create tag and build when new code gets to main / Test (push) Failing after 8m43s

This commit is contained in:
2026-02-22 16:49:58 +01:00
parent f3eea3f171
commit c9738d9c61
21 changed files with 3 additions and 612 deletions

View File

@@ -1,55 +0,0 @@
using Godot;
using GdUnit4;
using static GdUnit4.Assertions;
using Movementtests.interfaces;
using Movementtests.systems.damage;
namespace Movementtests.tests;
[TestSuite, RequireGodotRuntime]
public class HealthComponentUnitTest
{
[TestCase]
public void ReadyInitializesCurrentHealth()
{
var cHealth = new CHealth();
cHealth.RHealth = new RHealth(150.0f);
cHealth._Ready();
AssertFloat(cHealth.CurrentHealth).IsEqual(150.0f);
}
[TestCase]
public void ReduceHealthDecreasesAndDoesNotDeplete()
{
var cHealth = new CHealth();
cHealth.RHealth = new RHealth(100.0f);
cHealth.CurrentHealth = 100.0f;
var damage = new DamageRecord(Vector3.Zero, new RDamage(25.0f, EDamageTypes.Normal));
var record = cHealth.ReduceHealth(source: null!, damageRecord: damage);
AssertFloat(cHealth.CurrentHealth).IsEqual(75.0f);
AssertFloat(record.CurrentHealth).IsEqual(75.0f);
AssertFloat(record.PreviousHealth).IsEqual(100.0f);
AssertFloat(record.MaxHealth).IsEqual(100.0f);
}
[TestCase]
public void ReduceHealthTriggersDepletionToZero()
{
var cHealth = new CHealth();
cHealth.RHealth = new RHealth(50.0f);
cHealth.CurrentHealth = 50.0f;
bool depleted = false;
cHealth.HealthDepleted += _ => depleted = true;
var damage = new DamageRecord(Vector3.Zero, new RDamage(100.0f, EDamageTypes.Normal));
var record = cHealth.ReduceHealth(source: null!, damageRecord: damage);
AssertBool(depleted).IsTrue();
AssertFloat(cHealth.CurrentHealth).IsEqual(0.0f);
AssertFloat(record.CurrentHealth).IsEqual(-50.0f);
AssertFloat(record.MaxHealth).IsEqual(50.0f);
}
}