Exemplo n.º 1
0
        public void TestBonusChangedEvent()
        {
            StatBase stat = CreateStat(15);

            stat.BonusChanged += Stat_BonusChanged;

            // set base
            stat.Base = 13;
            AssertNoBonusChangedReceived();

            // set no bonus
            stat.SetBonus(BonusType.Haste, 0);
            AssertNoBonusChangedReceived();

            // set a bonus
            stat.SetBonus(BonusType.Haste, 3);
            AssertBonusChangedReceived();

            // set no bonus
            stat.SetBonus(BonusType.Haste, 3);
            AssertNoBonusChangedReceived();

            // add no bonus
            stat.AddBonus(BonusType.Haste, 0);
            AssertNoBonusChangedReceived();

            // add a bonus
            stat.AddBonus(BonusType.Haste, 3);
            AssertBonusChangedReceived();

            // drain
            stat.AddBonus(BonusType.Drain, -3);
            AssertBonusChangedReceived();

            // restore
            stat.Restore();
            AssertBonusChangedReceived();

            // restore when not needed
            stat.Restore();
            AssertNoBonusChangedReceived();

            stat.BonusChanged -= Stat_BonusChanged;

            // set to different value after unregistering
            stat.AddBonus(BonusType.Drain, -3);
            AssertNoBonusChangedReceived();
        }
Exemplo n.º 2
0
        public void TestHasBonus()
        {
            StatBase stat = CreateStat(15);

            Assert.IsFalse(stat.HasBonus(BonusType.Drain));

            stat.SetBonus(BonusType.Drain, 12);
            Assert.IsTrue(stat.HasBonus(BonusType.Drain));

            stat.AddBonus(BonusType.Drain, -12);
            Assert.IsFalse(stat.HasBonus(BonusType.Drain));
        }
Exemplo n.º 3
0
        public void TestGetBonus()
        {
            StatBase stat = CreateStat(15);

            Assert.AreEqual(0, stat.GetBonus(BonusType.Drain));

            stat.SetBonus(BonusType.Drain, 12);
            Assert.AreEqual(12, stat.GetBonus(BonusType.Drain));

            stat.AddBonus(BonusType.Drain, 2);
            Assert.AreEqual(14, stat.GetBonus(BonusType.Drain));
        }