changeset 184:00ea622313be

Re #366: Rewrite equipment handling and limits * Add test for numeric amounts to make sure that they're not affected either
author IBBoard <dev@ibboard.co.uk>
date Sat, 12 Nov 2011 20:49:11 +0000
parents bd38c32fb1a9
children ba9af0ce916a
files API/Objects/UnitEquipmentNumericSelectionTests.cs IBBoard.WarFoundry.API.Tests.csproj
diffstat 2 files changed, 52 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/API/Objects/UnitEquipmentNumericSelectionTests.cs	Sat Nov 12 20:49:11 2011 +0000
     1.3 @@ -0,0 +1,51 @@
     1.4 +// This file (UnitEquipmentRatioSelectionTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
     1.5 +// 
     1.6 +// 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.
     1.7 +using System;
     1.8 +using NUnit.Framework;
     1.9 +using IBBoard.WarFoundry.API.Util;
    1.10 +using IBBoard.WarFoundry.API.Factories;
    1.11 +using IBBoard.Limits;
    1.12 +using NUnit.Framework.SyntaxHelpers;
    1.13 +
    1.14 +namespace IBBoard.WarFoundry.API.Objects
    1.15 +{
    1.16 +	[TestFixture()]
    1.17 +	public class UnitEquipmentNumericSelectionTests
    1.18 +	{
    1.19 +		[Test()]
    1.20 +		public void Bug366TestAmountIsNotLimitedByRatioAmount()
    1.21 +		{
    1.22 +			DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
    1.23 +			Race race = new Race("race", "Race", new GameSystem("gs", "System", factory), factory);
    1.24 +			Category cat = new Category("cat1", "Category");
    1.25 +			race.AddCategory(cat);
    1.26 +			EquipmentItem equip1 = new EquipmentItem("equip1", "Equipment 1", race);
    1.27 +			race.AddEquipmentItem(equip1);
    1.28 +			EquipmentItem equip2 = new EquipmentItem("equip2", "Equipment 2", race);
    1.29 +			race.AddEquipmentItem(equip2);
    1.30 +			UnitType unitType = new UnitType("type1", "UnitType", race);
    1.31 +			unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(33, true));
    1.32 +			UnitEquipmentItem unitEquip1 = new UnitEquipmentItem(equip1, unitType);
    1.33 +			unitEquip1.SlotName = "slot";
    1.34 +			unitEquip1.RoundNumberUp = true;
    1.35 +			unitEquip1.MinLimit = new SimpleRoundedPercentageLimit(0);
    1.36 +			unitEquip1.MaxLimit = new SimpleRoundedPercentageLimit(33, true);
    1.37 +			UnitEquipmentItem unitEquip2 = new UnitEquipmentItem(equip2, unitType);
    1.38 +			unitEquip2.SlotName = "slot";
    1.39 +			unitEquip2.RoundNumberUp = true;
    1.40 +			unitEquip2.MinLimit = new SimpleRoundedPercentageLimit(0);
    1.41 +			unitEquip2.MaxLimit = new SimpleRoundedPercentageLimit(33, true);
    1.42 +			race.AddUnitType(unitType);
    1.43 +			Army army = new Army(race, "army", 1000);
    1.44 +			Unit unit = new Unit(unitType, army.GetCategory(cat));
    1.45 +			unit.Size = 3;
    1.46 +			unit.SetEquipmentAmount(unitEquip2, 1);
    1.47 +			unit.SetEquipmentRatio(unitEquip1, 33);
    1.48 +			Assert.That(UnitEquipmentUtil.GetEquipmentAmount(unit, unitEquip2), Is.EqualTo(1));
    1.49 +			Assert.That(UnitEquipmentUtil.GetEquipmentAmountTaken(unit, unitEquip2), Is.EqualTo(1));
    1.50 +			Assert.That(unit.GetEquipmentAmountInSlot("slot"), Is.EqualTo(2));
    1.51 +		}
    1.52 +	}
    1.53 +}
    1.54 +
     2.1 --- a/IBBoard.WarFoundry.API.Tests.csproj	Sat Nov 12 20:36:58 2011 +0000
     2.2 +++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Nov 12 20:49:11 2011 +0000
     2.3 @@ -111,6 +111,7 @@
     2.4      <Compile Include="API\Factories\Mock\MockNativeWarFoundryFactory.cs" />
     2.5      <Compile Include="API\Objects\UnitEquipmentLimitTests.cs" />
     2.6      <Compile Include="API\Objects\UnitEquipmentRatioSelectionTests.cs" />
     2.7 +    <Compile Include="API\Objects\UnitEquipmentNumericSelectionTests.cs" />
     2.8    </ItemGroup>
     2.9    <ItemGroup>
    2.10      <None Include="app.config" />