Esempio n. 1
0
    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!");
    }
Esempio n. 2
0
    public void Test_AttackingAnOpponentReturnsTrueAfterLandingAHit()
    {
        FighterStatsClass stats1 = new FighterStatsClass();
        FighterStatsClass stats2 = new FighterStatsClass();

        int  fullHealth    = stats2.GetCurrentHealth();
        bool landedHit     = stats1.AttackOpponent(stats2, false, true);
        int  damagedHealth = stats2.GetCurrentHealth();

        Assert.Less(damagedHealth, fullHealth, "Fighter wasn't able to attack another fighter and damage them!");
        Assert.IsTrue(landedHit, "AttackOpponent() did not return true after landing a hit!");
    }
Esempio n. 3
0
    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!");
    }
Esempio n. 4
0
    public void Test_FighterCanAttackAnotherFighter()
    {
        FighterStatsClass stats1 = new FighterStatsClass();
        FighterStatsClass stats2 = new FighterStatsClass();

        int fullHealth = stats2.GetCurrentHealth();

        stats1.AttackOpponent(stats2, false, true);
        int damagedHealth = stats2.GetCurrentHealth();

        Assert.Less(damagedHealth, fullHealth,
                    "Fighter wasn't able to attack another fighter and damage them!");
    }
Esempio n. 5
0
    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!");
    }
Esempio n. 6
0
    public void Test_FighterCannotDodgeUnavoidableAttack()
    {
        FighterStatsClass stats1 = new FighterStatsClass();
        FighterStatsClass stats2 = new FighterStatsClass();

        stats2.DodgePropability = 1f;

        int fullHealth = stats2.GetCurrentHealth();

        stats1.AttackOpponent(stats2, false, true);
        int afterAttack = stats2.GetCurrentHealth();

        Assert.Less(afterAttack, fullHealth, "Fighter was able to dodge unavoidable attack!");
    }
Esempio n. 7
0
    public void Test_FighterCanDodgeIncomingAttack()
    {
        FighterStatsClass stats1 = new FighterStatsClass();
        FighterStatsClass stats2 = new FighterStatsClass();

        stats2.DodgePropability = 1f;

        int fullHealth = stats2.GetCurrentHealth();

        stats1.AttackOpponent(stats2, true, true);
        int afterAttack = stats2.GetCurrentHealth();

        Assert.AreEqual(fullHealth, afterAttack, "Fighter wasn't able to dodge incoming attack!");
        LogAssert.Expect(LogType.Error, "ShowDodge() must be implemented inside the sub-class!");
    }
Esempio n. 8
0
    public void Test_AttackingAnOpponentReturnsFalseAfterOpponentDodged()
    {
        FighterStatsClass stats1 = new FighterStatsClass();
        FighterStatsClass stats2 = new FighterStatsClass();

        stats2.DodgePropability = 1;

        int  fullHealth    = stats2.GetCurrentHealth();
        bool landedHit     = stats1.AttackOpponent(stats2, true, true);
        int  damagedHealth = stats2.GetCurrentHealth();

        LogAssert.Expect(LogType.Error, "ShowDodge() must be implemented inside the sub-class!");
        Assert.AreEqual(damagedHealth, fullHealth, "Attacked opponent did not dodge as expected!");
        Assert.IsFalse(landedHit, "AttackOpponent() did not return false after the opponent dodged!");
    }
Esempio n. 9
0
    public void Test_FighterHealthCannotDropUnderZero()
    {
        const int         heavyDamage = 200;
        FighterStatsClass stats       = new FighterStatsClass();

        stats.ReceiveDamage(heavyDamage);

        Assert.Zero(stats.GetCurrentHealth(), "Fighter health is not 0 after receiving massive damage!");
    }
Esempio n. 10
0
    public void Test_FighterDiesIfHealthDropsToZero()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int killDamage          = stats.GetCurrentHealth();

        stats.ReceiveDamage(killDamage);

        Assert.AreEqual(FighterState.dead, stats.GetCurrentFighterState(), "Fighter didn't die after health dropped to zero!");
    }
Esempio n. 11
0
    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!");
    }
Esempio n. 12
0
    public void Test_FighterBeginsWithMaximumHealth()
    {
        // Arrange
        FighterStatsClass stats = new FighterStatsClass();

        // Act

        // Assert
        Assert.AreEqual(stats.GetMaxHealth(), stats.GetCurrentHealth(), "Fighter didn't start with maximum health!");
    }
Esempio n. 13
0
    public void Test_FighterCannotDieTwice()
    {
        FighterStatsClass stats = new FighterStatsClass();
        int killDamage          = stats.GetCurrentHealth();

        stats.ReceiveDamage(killDamage);
        stats.ReceiveDamage(killDamage);

        LogAssert.Expect(LogType.Warning, "Fighter is already dead and can no longer receive any damage!");
    }
Esempio n. 14
0
    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!");
    }