Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 181:49b359624ea5
Re #356: Stack overflow with some equipment limits
* Add more values to data to test amount counting from various directions
Note: The end of this code highlights a larger bug/design flaw
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 06 Nov 2011 20:53:27 +0000 |
parents | ce40484ad921 |
children | e9be63d72b3c |
files | API/Objects/UnitEquipmentLimitTests.cs |
diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/API/Objects/UnitEquipmentLimitTests.cs Sun Nov 06 19:47:18 2011 +0000 +++ b/API/Objects/UnitEquipmentLimitTests.cs Sun Nov 06 20:53:27 2011 +0000 @@ -6,6 +6,7 @@ using IBBoard.WarFoundry.API.Factories; using IBBoard.Limits; using NUnit.Framework.SyntaxHelpers; +using IBBoard.WarFoundry.API.Util; namespace IBBoard.WarFoundry.API.Objects { @@ -20,17 +21,22 @@ Category cat = new Category("cat1", "Category"); race.AddCategory(cat); EquipmentItem equip1 = new EquipmentItem("equip1", "Equipment 1", race); + equip1.Cost = 3; race.AddEquipmentItem(equip1); EquipmentItem equip2 = new EquipmentItem("equip2", "Equipment 2", race); + equip2.Cost = 2; race.AddEquipmentItem(equip2); UnitType unitType = new UnitType("type1", "UnitType", race); + unitType.CostPerTrooper = 10; unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(34, false)); UnitEquipmentItem unitEquip1 = new UnitEquipmentItem(equip1, unitType); unitEquip1.SlotName = "slot"; + unitEquip1.RoundNumberUp = true; unitEquip1.MinLimit = new SimpleRoundedPercentageLimit(0); unitEquip1.MaxLimit = new SimpleRoundedPercentageLimit(33, true); UnitEquipmentItem unitEquip2 = new UnitEquipmentItem(equip2, unitType); unitEquip2.SlotName = "slot"; + unitEquip2.RoundNumberUp = true; unitEquip2.MinLimit = new SimpleRoundedPercentageLimit(0); unitEquip2.MaxLimit = new SimpleRoundedPercentageLimit(33, true); race.AddUnitType(unitType); @@ -38,8 +44,12 @@ Unit unit = new Unit(unitType, army.GetCategory(cat)); unit.Size = 3; unit.SetEquipmentRatio(unitEquip1, 33); + Assert.That(unit.GetEquipmentAmountInSlot("slot"), Is.EqualTo(1)); + Assert.That(UnitEquipmentUtil.GetMaxEquipmentCount(unit, unitEquip2), Is.EqualTo(0)); + Assert.That(unit.Points, Is.EqualTo(33)); unit.SetEquipmentRatio(unitEquip2, 0.7); - Assert.That(unit.GetEquipmentAmountInSlot("slot"), Is.EqualTo(1)); + Assert.That(unit.GetEquipmentAmountInSlot("slot"), Is.EqualTo(2)); + Assert.That(unit.Points, Is.EqualTo(35)); } } }