Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
changeset 14:19fc7a733064
Re #198: Add slots with counts to units
* Start testing unit
* Add more mock objects
* Make MockUnitType define its category
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 23 Oct 2009 19:57:03 +0000 |
parents | ca5d7c2c7493 |
children | 1119b6f48e8e |
files | API/Objects/Mock/MockArmy.cs API/Objects/Mock/MockArmyCategory.cs API/Objects/Mock/MockCategory.cs API/Objects/Mock/MockUnitEquipmentItem.cs API/Objects/Mock/MockUnitType.cs API/Objects/UnitTest.cs IBBoard.WarFoundry.API.Tests.csproj |
diffstat | 7 files changed, 106 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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) + { + } + } +}
--- /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) + { + } + } +}
--- /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") + { + } + } +}
--- /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; + } + } +}
--- 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(); } } }
--- /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)); + } + } +}
--- 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 @@ <Compile Include="API\Objects\Mock\MockRace.cs" /> <Compile Include="API\Factories\Mock\MockSystemFactory.cs" /> <Compile Include="API\Objects\Mock\MockGameSystem.cs" /> + <Compile Include="API\Objects\UnitTest.cs" /> + <Compile Include="API\Objects\Mock\MockArmyCategory.cs" /> + <Compile Include="API\Objects\Mock\MockArmy.cs" /> + <Compile Include="API\Objects\Mock\MockCategory.cs" /> + <Compile Include="API\Objects\Mock\MockUnitEquipmentItem.cs" /> </ItemGroup> <ItemGroup> <None Include="testdata\Test.race">