view API/Util/UnitEquipmentUtilTest.cs @ 132:8f1af48e120c

Re #27: Unit requirements * Add unit test for unit requirements in opposite order * Add unit test to make sure that requirement doesn't lock to first result, even after changes Also: * Clean up line endings to meet policy
author IBBoard <dev@ibboard.co.uk>
date Sun, 17 Apr 2011 19:34:48 +0000
parents 9bf542b76de2
children c026c02583ca
line wrap: on
line source

// 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.CustomMath;
using IBBoard.Limits;
using IBBoard.WarFoundry.API.Objects;
using IBBoard.WarFoundry.API.Objects.Mock;

namespace IBBoard.WarFoundry.API.Util
{
	[TestFixture()]
	public class UnitEquipmentUtilTest
	{
		private const string SLOT_NAME = "slot";
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnDefaultSlot()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(4);
			UnitType unitType = equip.EquipmentForUnit;
			Unit unit = GetUnit (unitType);
			Assert.AreEqual(4, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(4, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(4, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(4, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnDefaultSlotWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1,4);
			UnitType unitType = equip.EquipmentForUnit;
			Unit unit = GetUnit (unitType);
			Assert.AreEqual(4, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(4, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlot()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithMaxBelowSlotLimit()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithMaxBelowSlotLimitWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
				
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnPercentageLimitedSlot()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(10);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, false));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnPercentageLimitedSlotWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(5, 10);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, false));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(5, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(5, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipment()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(6));
			Unit unit =GetUnit(unitType);
			UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
			equip2.SlotName = SLOT_NAME;
			unit.SetEquipmentAmount(equip2, 5);
			Assert.AreEqual(1, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipmentOfSameType()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(3));
			Unit unit =GetUnit(unitType);
			unit.SetEquipmentAmount(equip, 2);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(3, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForFixedLimitItemOnNumberLimitedSlotWithExistingEquipmentDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem(1, 3);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(7));
			Unit unit =GetUnit(unitType);
			UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
			equip2.SlotName = SLOT_NAME;
			unit.SetEquipmentAmount(equip2, 5);
			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(1, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnDefaultSlot()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
			UnitType unitType = equip.EquipmentForUnit;
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnDefaultSlotWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(25, 50);
			UnitType unitType = equip.EquipmentForUnit;
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(25, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlot()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(2));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlot()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(25, false));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(25, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(25, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(25, false));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(25, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithMaxBelowSlotLimit()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(75, false));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(7, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithMaxBelowSlotLimitWithDifferentMinLimit()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(25, 50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(75, false));
			Unit unit = GetUnit(unitType);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(25, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithExistingEquipment()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(7));
			Unit unit = GetUnit(unitType);
			UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
			equip2.SlotName = SLOT_NAME;
			unit.SetEquipmentAmount(equip2, 5);
			Assert.AreEqual(2, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(2, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(IBBMath.Percentage(2, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnNumberLimitedSlotWithExistingEquipmentOfSameType()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(10));
			Unit unit = GetUnit(unitType);
			unit.SetEquipmentAmount(equip, 5);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipment()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
			Unit unit = GetUnit(unitType);
			UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
			equip2.SlotName = SLOT_NAME;
			unit.SetEquipmentAmount(equip2, 5);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(3, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50 - IBBMath.Percentage(5, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(50 - IBBMath.Percentage(5, 15), UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipmentOfSameType()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
			Unit unit = GetUnit(unitType);
			unit.SetEquipmentAmount(equip, 5);
			Assert.AreEqual(7, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50, UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestGetEquipmentCountsForPercentageLimitItemOnPercentageLimitedSlotWithExistingEquipmentWithDifferentMinimum()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem(10, 50);
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
			Unit unit = GetUnit(unitType);
			UnitEquipmentItem equip2 = new MockPercentageAmountUnitEquipmentItem(new MockEquipmentItem("equip2"), unitType);
			equip2.SlotName = SLOT_NAME;
			unit.SetEquipmentAmount(equip2, 5);
			Assert.AreEqual(3, UnitEquipmentUtil.GetMaxEquipmentCount(unit, equip));
			Assert.AreEqual(1, UnitEquipmentUtil.GetMinEquipmentCount(unit, equip));
			Assert.AreEqual(50 - IBBMath.Percentage(5, 15), UnitEquipmentUtil.GetMaxEquipmentPercentage(unit, equip));
			Assert.AreEqual(10, UnitEquipmentUtil.GetMinEquipmentPercentage(unit, equip));
		}
		
		[Test()]
		public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndUnlimitedSlot()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();			
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new UnlimitedLimit());
			Unit unit = GetUnit(unitType);
			Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
		}
		
		[Test()]
		public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndRatioSlot()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
			Unit unit = GetUnit(unitType);
			Assert.IsTrue(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
		}
		
		[Test()]
		public void TestIsEquipmentRatioLimitsWithRatioLimitedEquipmentAndAbsoluteSlot()
		{
			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
			Unit unit = GetUnit(unitType);
			Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
		}
		
		[Test()]
		public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndAbsoluteSlot()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new AbsoluteNumericLimit(5));
			Unit unit = GetUnit(unitType);
			Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
		}
		
		[Test()]
		public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndUnlimitedSlot()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new UnlimitedLimit());
			Unit unit = GetUnit(unitType);
			Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
		}
		
		[Test()]
		public void TestIsEquipmentRatioLimitsWithAbsoluteLimitedEquipmentAndRatioSlot()
		{
			UnitEquipmentItem equip = new MockNumericAmountUnitEquipmentItem();
			equip.SlotName = SLOT_NAME;
			UnitType unitType = equip.EquipmentForUnit;
			unitType.AddEquipmentSlot(SLOT_NAME, new SimpleRoundedPercentageLimit(50, true));
			Unit unit = GetUnit(unitType);
			Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
		}
		
		private Unit GetUnit (UnitType unitType)
		{
			return new Unit ("unit", "Test Unit", 15, unitType, new MockArmyCategory (unitType.MainCategory));
		}
	}
}