public void TestSetBonus() { FluidStat stat = new FluidStat(15); Assert.AreEqual(15, stat.Base); Assert.AreEqual(15, stat.Max); Assert.AreEqual(15, stat.Current); stat.SetBonus(BonusType.Equipment, 2); Assert.AreEqual(15, stat.Base); Assert.AreEqual(17, stat.Max); Assert.AreEqual(15, stat.Current); stat.SetBonus(BonusType.Equipment, 0); Assert.AreEqual(15, stat.Base); Assert.AreEqual(15, stat.Max); Assert.AreEqual(15, stat.Current); stat.SetBonus(BonusType.Equipment, -4); Assert.AreEqual(15, stat.Base); Assert.AreEqual(11, stat.Max); Assert.AreEqual(11, stat.Current); stat.SetBonus(BonusType.Haste, 2); Assert.AreEqual(15, stat.Base); Assert.AreEqual(13, stat.Max); Assert.AreEqual(11, stat.Current); }
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(); }