# HG changeset patch # User IBBoard # Date 1256327823 0 # Node ID 19fc7a733064284c81fbad8216ee6360807d64ab # Parent ca5d7c2c749325f8c364ba940ecf5fe03c70add2 Re #198: Add slots with counts to units * Start testing unit * Add more mock objects * Make MockUnitType define its category diff -r ca5d7c2c7493 -r 19fc7a733064 API/Objects/Mock/MockArmy.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Mock/MockArmy.cs Fri Oct 23 19:57:03 2009 +0000 @@ -0,0 +1,27 @@ +// This file (MockArmy.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; + +namespace IBBoard.WarFoundry.API.Objects.Mock +{ + public class MockArmy : Army + { + private static MockArmy mockArmy; + + public static MockArmy GetMockArmy () + { + if (mockArmy == null) + { + mockArmy = new MockArmy (); + } + + return mockArmy; + } + + private MockArmy () : base(MockRace.GetMockRace (), "Mock Army", 2000) + { + } + } +} diff -r ca5d7c2c7493 -r 19fc7a733064 API/Objects/Mock/MockArmyCategory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Mock/MockArmyCategory.cs Fri Oct 23 19:57:03 2009 +0000 @@ -0,0 +1,15 @@ +// This file (MockArmyCategory.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; + +namespace IBBoard.WarFoundry.API.Objects.Mock +{ + public class MockArmyCategory : ArmyCategory + { + public MockArmyCategory (Category cat) : base(MockArmy.GetMockArmy(), cat) + { + } + } +} diff -r ca5d7c2c7493 -r 19fc7a733064 API/Objects/Mock/MockCategory.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Mock/MockCategory.cs Fri Oct 23 19:57:03 2009 +0000 @@ -0,0 +1,15 @@ +// This file (MockCategory.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; + +namespace IBBoard.WarFoundry.API.Objects.Mock +{ + public class MockCategory : Category + { + public MockCategory () : base("mockcat", "Mock Category") + { + } + } +} diff -r ca5d7c2c7493 -r 19fc7a733064 API/Objects/Mock/MockUnitEquipmentItem.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/Mock/MockUnitEquipmentItem.cs Fri Oct 23 19:57:03 2009 +0000 @@ -0,0 +1,18 @@ +// This file (MockUnitEquipmentItem.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; + +namespace IBBoard.WarFoundry.API.Objects.Mock +{ + public class MockUnitEquipmentItem : UnitEquipmentItem + { + + public MockUnitEquipmentItem () : base(new MockEquipmentItem(), new MockUnitType()) + { + MaxPercentage = 100; //TODO: This seems odd - maybe IsRatio should be "!=0" + MaxNumber = WarFoundryCore.INFINITY; + } + } +} diff -r ca5d7c2c7493 -r 19fc7a733064 API/Objects/Mock/MockUnitType.cs --- a/API/Objects/Mock/MockUnitType.cs Mon Oct 12 19:50:48 2009 +0000 +++ b/API/Objects/Mock/MockUnitType.cs Fri Oct 23 19:57:03 2009 +0000 @@ -11,6 +11,7 @@ { public MockUnitType () : base("mockunittype", "Mock Unit Type", MockRace.GetMockRace()) { + MainCategory = new MockCategory(); } } } diff -r ca5d7c2c7493 -r 19fc7a733064 API/Objects/UnitTest.cs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/API/Objects/UnitTest.cs Fri Oct 23 19:57:03 2009 +0000 @@ -0,0 +1,25 @@ +// This file (UnitTest.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.WarFoundry.API.Objects.Mock; + +namespace IBBoard.WarFoundry.API.Objects +{ + [TestFixture()] + public class UnitTest + { + [Test()] + public void TestAddSlotEquipmentAddsEquipmentSelection() + { + UnitEquipmentItem equip = new MockUnitEquipmentItem(); + UnitType unitType = equip.EquipmentForUnit; + Unit unit = new Unit(unitType, new MockArmyCategory(unitType.MainCategory)); + unit.SetEquipmentAmount(equip, WarFoundryCore.INFINITY); + Assert.AreEqual(WarFoundryCore.INFINITY, unit.GetEquipmentAmount(equip)); + Assert.IsFalse(unit.GetEquipmentAmountIsRatio(equip)); + } + } +} diff -r ca5d7c2c7493 -r 19fc7a733064 IBBoard.WarFoundry.API.Tests.csproj --- a/IBBoard.WarFoundry.API.Tests.csproj Mon Oct 12 19:50:48 2009 +0000 +++ b/IBBoard.WarFoundry.API.Tests.csproj Fri Oct 23 19:57:03 2009 +0000 @@ -49,6 +49,11 @@ + + + + +