public void DurabilityService_SetDurability_ShouldSetToDefaultValue() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); DurabilityService service = new DurabilityService(script, color); float value = 0.0f; NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => BASE_ITEM_LONGSWORD); item.When(x => x.SetLocalFloat(Arg.Any <string>(), Arg.Any <float>())) .Do(x => value = x.ArgAt <float>(1)); service.SetDurability(item, -50.0f); Assert.AreEqual(0.0f, value); }
public void DurabilityService_SetDurability_ShouldSetToSpecifiedValue() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); DurabilityService service = new DurabilityService(script, color); float value = 0.0f; NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => BASE_ITEM_LONGSWORD); item.When(x => x.SetLocalFloat("DURABILITY_CURRENT", Arg.Any <float>())) .Do(x => value = x.ArgAt <float>(1)); service.SetDurability(item, 12.52f); Assert.AreEqual(12.52f, value); }
public void DurabilityService_SetDurability_InvalidType_ShouldNotRunOnce() { INWScript script = Substitute.For <INWScript>(); IColorTokenService color = Substitute.For <IColorTokenService>(); DurabilityService service = new DurabilityService(script, color); bool ranOnce = false; NWItem item = Substitute.For <NWItem>(script, service); item.BaseItemType.Returns(x => BASE_ITEM_BLANK_SCROLL); item.When(x => x.SetLocalFloat(Arg.Any <string>(), Arg.Any <float>())) .Do(x => ranOnce = true); service.SetDurability(item, 999.0f); Assert.AreEqual(false, ranOnce); }