Exemplo n.º 1
0
    public void Test_FighterCannotAttackNullPointer()
    {
        FighterStatsClass stats1 = new FighterStatsClass();
        FighterStatsClass stats2 = null;

        stats1.AttackOpponent(stats2, false, true);

        LogAssert.Expect(LogType.Warning, "Fighter tried to attack an opponent that's a nnullpointer. Can't attack non-existant opponents!");
    }
Exemplo n.º 2
0
    public void Test_FighterCannotAttackWithoutWaitingTurnTime()
    {
        FighterStatsClass stats = new FighterStatsClass();
        FighterStatsClass enemy = new FighterStatsClass();

        Assert.IsFalse(stats.CanAct(), "Fighter was able to attack without having to wait their turn time!");

        stats.AttackOpponent(enemy, false);

        LogAssert.Expect(LogType.Warning, "Tried to attack an opponent when not allowed to do that!");
    }
Exemplo n.º 3
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!");
    }
Exemplo 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!");
    }
Exemplo n.º 5
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!");
    }
Exemplo n.º 6
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!");
    }
Exemplo n.º 7
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!");
    }