public void calculates_added_modifier() { // Arange IAttribute attr = new Attribute(); AttributeModifier mod = new AttributeModifier(1f, AttrModType.Flat); // Act float actualBaseValue = attr.BaseValue; AttrProcessor.AddModifier(ref attr, mod); float actualValue = attr.Value; // Assert Assert.AreEqual(0f, actualBaseValue); Assert.AreEqual(1f, actualValue); }
public void correctly_sorts_and_calculates_multiple_modifier_types() { // Arrange IAttribute attr = new Attribute(10); AttributeModifier modFlat = new AttributeModifier(100f, AttrModType.Flat); AttributeModifier modPercentAdd1 = new AttributeModifier(0.025f, AttrModType.PercentAdd); AttributeModifier modPercentAdd2 = new AttributeModifier(0.025f, AttrModType.PercentAdd); AttributeModifier modPercentMult = new AttributeModifier(0.05f, AttrModType.PercentMult); // Act AttrProcessor.AddModifier(ref attr, modFlat); AttrProcessor.AddModifier(ref attr, modPercentAdd1); AttrProcessor.AddModifier(ref attr, modPercentAdd2); AttrProcessor.AddModifier(ref attr, modPercentMult); float actualValue = attr.Value; // Assert Assert.AreEqual(121f, Mathf.Round(actualValue)); }
public void removed_modifier_successfully() { // Arrange IAttribute attr = new Attribute(); AttributeModifier mod = new AttributeModifier(10f, AttrModType.Flat); // Act float actualBaseValue = attr.BaseValue; AttrProcessor.AddModifier(ref attr, mod); float actualValueWithModifier = attr.Value; AttrProcessor.RemoveModifier(ref attr, mod); float actualValue = attr.Value; // Assert Assert.AreEqual(0f, actualBaseValue); Assert.AreEqual(10f, actualValueWithModifier); Assert.AreEqual(0f, actualValue); }