# HG changeset patch # User IBBoard # Date 1256410770 0 # Node ID e8e7554fb7f38f82ab1c5c033db0d2b9be871a66 # Parent 4480d7151d358ed47972c625ca4dbf00a2af4714 Re #198: Add slots with count * Add initial unit equipment util tests diff -r 4480d7151d35 -r e8e7554fb7f3 API/Util/UnitEquipmentUtilTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Util/UnitEquipmentUtilTest.cs Sat Oct 24 18:59:30 2009 +0000 @@ -0,0 +1,37 @@ +// This file (UnitEquipmentItemUtilTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard +// +// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. + +using System; +using NUnit.Framework; +using IBBoard.Limits; +using IBBoard.WarFoundry.API.Objects; +using IBBoard.WarFoundry.API.Objects.Mock; + +namespace IBBoard.WarFoundry.API.Util +{ + [TestFixture()] + public class UnitEquipmentUtilTest + { + [Test()] + public void TestGetMaxEquipmentCountForFixedLimitItemOnDefaultSlot() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); + equip.MaxNumber = 3; + UnitType unitType = equip.EquipmentForUnit; + Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory)); + Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); + } + + [Test()] + public void TestGetMaxEquipmentCountForFixedLimitItemOnNumberLimitedSlot() + { + UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(); + equip.MaxNumber = 3; + UnitType unitType = equip.EquipmentForUnit; + unitType.AddEquipmentSlot("slot", new AbsoluteNumericLimit(2)); + Unit unit = new MockUnit(unitType, new MockArmyCategory(unitType.MainCategory)); + Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip)); + } + } +} diff -r 4480d7151d35 -r e8e7554fb7f3 IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Sat Oct 24 14:04:43 2009 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Sat Oct 24 18:59:30 2009 +0000 @@ -56,6 +56,7 @@ + @@ -78,6 +79,10 @@ {951E6C7A-7FBA-4F68-9D9E-F48618BB9626} IBBoard.WarFoundry.API + + {5DFD64F6-FC2B-4B4F-B92E-483BAC468105} + IBBoard + @@ -85,6 +90,7 @@ +