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

            Assert.AreEqual(15, stat.Base);
            Assert.AreEqual(15, stat.Max);
            Assert.AreEqual(15, stat.Current);

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

            bool restored = stat.Restore();

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

            restored = stat.Restore();
            Assert.IsFalse(restored);
        }
Ejemplo n.º 2
0
        public void TestChangedEvent()
        {
            FluidStat stat = new FluidStat(15);

            stat.Changed += Stat_Changed;

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

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

            // set to same current
            stat.Current = 13;
            AssertNoChangedReceived();

            // set to same current (clamped)
            stat.Current = 25;
            AssertNoChangedReceived();

            // set to different current
            stat.Current = 8;
            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();
        }