diff API/Util/UnitEquipmentUtilTest.cs @ 183:bd38c32fb1a9

Re #366: Rewrite equipment handling and limits * Remove comment added during #356 - now resolved * Add test for behaviour of percentages * Add test for new "calculate number taken" util method
author IBBoard <dev@ibboard.co.uk>
date Sat, 12 Nov 2011 20:36:58 +0000
parents c026c02583ca
children e173c5512067
line wrap: on
line diff
--- a/API/Util/UnitEquipmentUtilTest.cs	Sun Nov 06 21:02:00 2011 +0000
+++ b/API/Util/UnitEquipmentUtilTest.cs	Sat Nov 12 20:36:58 2011 +0000
@@ -8,6 +8,7 @@
 using IBBoard.Limits;
 using IBBoard.WarFoundry.API.Objects;
 using IBBoard.WarFoundry.API.Objects.Mock;
+using NUnit.Framework.SyntaxHelpers;
 
 namespace IBBoard.WarFoundry.API.Util
 {
@@ -427,6 +428,20 @@
 			Unit unit = GetUnit(unitType);
 			Assert.IsFalse(UnitEquipmentUtil.IsEquipmentRatioLimited(unit, equip));
 		}
+
+		[Test()]
+		public void TestCalculateEquipmentAmountTakenFromRatio()
+		{
+			UnitEquipmentItem equip = new MockPercentageAmountUnitEquipmentItem();
+			UnitType unitType = equip.EquipmentForUnit;
+			Unit unit = GetUnit(unitType);
+			Assert.That(UnitEquipmentUtil.CalculateEquipmentAmountTakenFromRatio(unit, equip, 33.4), Is.EqualTo(5));
+			Assert.That(UnitEquipmentUtil.CalculateEquipmentAmountTakenFromRatio(unit, equip, 50), Is.EqualTo(7));
+			equip.RoundNumberUp = true;
+			Assert.That(UnitEquipmentUtil.CalculateEquipmentAmountTakenFromRatio(unit, equip, 33.4), Is.EqualTo(6));
+			Assert.That(UnitEquipmentUtil.CalculateEquipmentAmountTakenFromRatio(unit, equip, 50), Is.EqualTo(8));
+
+		}
 		
 		private Unit GetUnit (UnitType unitType)
 		{