view API/Objects/UnitEquipmentItemTest.cs @ 84:168c5aab34bb

Re #99: Define "points" values in GameSystem * Add tests for fall-back so that just one value can be specified
author IBBoard <dev@ibboard.co.uk>
date Sun, 20 Feb 2011 15:59:33 +0000
parents 2395dc131401
children
line wrap: on
line source

// This file (UnitEquipmentItemTests.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.Limits;
using IBBoard.WarFoundry.API.Objects.Mock;

namespace IBBoard.WarFoundry.API.Objects
{
	[TestFixture()]
	public class UnitEquipmentItemTest
	{
		[Test()]
		public void DefaultMinMaxNumberLimitsAre100Percent()
		{
			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
			Assert.IsTrue(item.MinLimit is IPercentageLimit);
			Assert.AreEqual(100, ((IPercentageLimit)item.MinLimit).Percentage);
			Assert.IsTrue(item.MaxLimit is IPercentageLimit);
			Assert.AreEqual(100, ((IPercentageLimit)item.MaxLimit).Percentage);
		}
		
		[Test()]
		public void MinNumberLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
		{
			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
			item.MaxLimit = new AbsoluteNumericLimit(1);
			Assert.AreEqual(item.MaxLimit, item.MinLimit);
		}
		
		[Test()]
		public void MaxNumberLimitEqualsMinLimitWhenOnlyMinLimitSet()
		{
			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
			item.MinLimit = new AbsoluteNumericLimit(1);
			Assert.AreEqual(item.MinLimit, item.MaxLimit);
		}
		
		[Test()]
		public void MinNumberLimitUntouchedWhenSetFirst()
		{
			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
			AbsoluteNumericLimit limit = new AbsoluteNumericLimit(1);
			item.MinLimit = limit;
			item.MaxLimit = new AbsoluteNumericLimit(10);
			Assert.AreEqual(limit, item.MinLimit);
		}
		
		[Test()]
		public void EqualNumberLimitsDoesntFail()
		{
			UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
			item.MaxLimit = new AbsoluteNumericLimit(10);
			item.MinLimit = new AbsoluteNumericLimit(10);
			item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
			item.MinLimit = new AbsoluteNumericLimit(10);
			item.MaxLimit = new AbsoluteNumericLimit(10);
		}
	}
}