public void Test_FighterHealthCannotExceedMaxHealth() { FighterStatsClass stats = new FighterStatsClass(); const int heal = 20; stats.GetHealedBy(heal); Assert.AreEqual(stats.GetMaxHealth(), stats.GetCurrentHealth(), "Fighter health changed after healing with full health!"); Assert.LessOrEqual(stats.GetCurrentHealth(), stats.GetMaxHealth(), "Fighter health exceeds full health after healing!"); }
public void Test_FighterCanBeDamaged() { FighterStatsClass stats = new FighterStatsClass(); const int damage = 10; int expectedHealth = stats.GetMaxHealth() - damage; stats.ReceiveDamage(damage); Assert.AreNotEqual(stats.GetMaxHealth(), stats.GetCurrentHealth(), "Fighter health didn't change after being damaged!"); Assert.Less(stats.GetCurrentHealth(), stats.GetMaxHealth(), "Fighter health somehow increased after being damaged!"); Assert.AreEqual(expectedHealth, stats.GetCurrentHealth(), "Fighter health is not at the expected value after being damaged!"); }
public void Test_FighterIsOnLastBreathWhileHealthBelowThreshhold() { FighterStatsClass stats = new FighterStatsClass(); int lastBreathDamage = Mathf.FloorToInt(stats.GetMaxHealth() - (stats.GetLastBreathThreshold() * stats.GetMaxHealth())); stats.ReceiveDamage(lastBreathDamage); Assert.AreEqual(FighterState.lastBreath, stats.GetCurrentFighterState(), "Fighter didn't get to last breath after his health dropped below the threshold!"); }
public void Test_FighterCannotReceiveNegativeDamage() { FighterStatsClass stats = new FighterStatsClass(); const int wrongDamage = -30; stats.ReceiveDamage(wrongDamage); LogAssert.Expect(LogType.Warning, "Fighter cannot receive negative damage. Health will not be modified."); Assert.AreEqual(stats.GetMaxHealth(), stats.GetCurrentHealth(), "Fighter health was modified by negative damage!"); }
public void Test_FighterBeginsWithMaximumHealth() { // Arrange FighterStatsClass stats = new FighterStatsClass(); // Act // Assert Assert.AreEqual(stats.GetMaxHealth(), stats.GetCurrentHealth(), "Fighter didn't start with maximum health!"); }
public void Test_FighterCanRevoverFromLastBreath() { FighterStatsClass stats = new FighterStatsClass(); int lastBreathDamage = Mathf.FloorToInt(stats.GetMaxHealth() - (stats.GetLastBreathThreshold() * stats.GetMaxHealth())); const int heal = 10; stats.ReceiveDamage(lastBreathDamage); Assert.AreEqual(FighterState.lastBreath, stats.GetCurrentFighterState(), "Fighter didn't get to last breath after his health dropped below the threshold!"); stats.GetHealedBy(heal); Assert.AreEqual(FighterState.alive, stats.GetCurrentFighterState(), "Fighter didn't recover from last breath after his health exceeded the threshold!"); }
public void Test_FighterCannotReceiveNegativeHealing() { FighterStatsClass stats = new FighterStatsClass(); const int damage = 30; const int wrongHeal = -20; int expectedHealth = stats.GetMaxHealth() - damage; stats.ReceiveDamage(damage); stats.GetHealedBy(wrongHeal); LogAssert.Expect(LogType.Warning, "Fighter cannot be healed by a negative amount. Health will not be modified."); Assert.AreEqual(expectedHealth, stats.GetCurrentHealth(), "Fighter health was modified by negative healing!"); }
public void Test_FighterCanBeHealed() { FighterStatsClass stats = new FighterStatsClass(); const int damage = 30; const int heal = 20; int damagedHealth = stats.GetMaxHealth() - damage; int expectedHealth = damagedHealth + heal; stats.ReceiveDamage(damage); stats.GetHealedBy(heal); Assert.AreEqual(expectedHealth, stats.GetCurrentHealth(), "Fighter health is not at the expected value after healing!"); Assert.AreNotEqual(damagedHealth, stats.GetCurrentHealth(), "Fighter health didn't change after healing!"); }