Ejemplo n.º 1
0
        public void TestChangedEvent()
        {
            Stat stat = new Stat(15);

            stat.Changed += Stat_Changed;

            // set to same value
            stat.Base = 15;
            AssertNoChangedReceived();

            // set to different value
            stat.Base = 13;
            AssertChangedReceived();

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

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

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

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

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

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

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

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

            stat.Changed -= Stat_Changed;

            // set to different value after unregistering
            stat.Base = 17;
            AssertNoChangedReceived();
        }
Ejemplo n.º 2
0
        public void TestAddBonus()
        {
            Stat stat = new Stat(15);

            Assert.AreEqual(15, stat.Current);

            stat.AddBonus(BonusType.Drain, 2);
            Assert.AreEqual(17, stat.Current);

            stat.AddBonus(BonusType.Drain, 0);
            Assert.AreEqual(17, stat.Current);

            stat.AddBonus(BonusType.Drain, -4);
            Assert.AreEqual(13, stat.Current);

            stat.AddBonus(BonusType.Drain, -1000);
            Assert.AreEqual(Stat.TotalMin, stat.Current);

            stat.AddBonus(BonusType.Equipment, 4000);
            Assert.AreEqual(Stat.TotalMax, stat.Current);
        }
Ejemplo n.º 3
0
        public void TestRestore()
        {
            Stat stat = new Stat(15);

            Assert.AreEqual(15, stat.Current);

            stat.AddBonus(BonusType.Drain, -2);
            Assert.AreEqual(13, stat.Current);

            bool restored = stat.Restore();

            Assert.IsTrue(restored);
            Assert.AreEqual(15, stat.Current);

            restored = stat.Restore();
            Assert.IsFalse(restored);
        }