Mercurial > repos > IBBoard.WarFoundry.API.Tests
view API/Objects/UnitEquipmentItemTest.cs @ 12:a4e7e938d065
Re #195: Setting max equipment without min may not function correctly
* Initial commit of tests for limits (percentage and numeric)
Also:
* Reshuffle and refactoring of existing tests
* Additional mocks required by the new tests
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Mon, 12 Oct 2009 19:42:30 +0000 |
parents | |
children | ca5d7c2c7493 |
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.WarFoundry.API.Objects.Mock; namespace IBBoard.WarFoundry.API.Objects { [TestFixture()] public class UnitEquipmentItemTest { [Test()] public void DefaultMinMaxNumberLimitsAreZero() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); Assert.AreEqual(0, item.MinNumber); Assert.AreEqual(0, item.MaxNumber); } [Test()] public void MinNumberLimitEqualsMaxLimitWhenOnlyMaxLimitSet() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MaxNumber = 1; Assert.AreEqual(1, item.MinNumber); } [Test()] public void MinNumberLimitUntouchedWhenSetFirst() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MinNumber = 1; item.MaxNumber = 10; Assert.AreEqual(1, item.MinNumber); } [Test()] public void MinNumberLimitSetToMaxWhenMaxLessThanMin() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MinNumber = 10; item.MaxNumber = 1; Assert.AreEqual(1, item.MinNumber); } [Test()] public void MaxNumberLimitSetToMinWhenMinGreaterThanMax() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MaxNumber = 1; item.MinNumber = 10; Assert.AreEqual(10, item.MaxNumber); } [Test()] public void EqualNumberLimitsDoesntFail() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MaxNumber = 10; item.MinNumber = 10; item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MinNumber = 10; item.MaxNumber = 10; } [Test()] public void DefaultMinMaxPercentageLimitsAreZero() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); Assert.AreEqual(0, item.MinPercentage); Assert.AreEqual(0, item.MaxPercentage); } [Test()] public void MinPercentLimitEqualsMaxLimitWhenOnlyMaxLimitSet() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MaxPercentage = 50; Assert.AreEqual(50, item.MinPercentage); } [Test()] public void MinPercentLimitUntouchedWhenSetFirst() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MinPercentage = 25; item.MaxPercentage = 50; Assert.AreEqual(25, item.MinPercentage); } [Test()] public void MinPercentLimitSetToMaxWhenMaxLessThanMin() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MinNumber = 50; item.MaxPercentage = 25; Assert.AreEqual(25, item.MinPercentage); } [Test()] public void MaxPercentLimitSetToMinWhenMinGreaterThanMax() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MaxPercentage = 25; item.MinPercentage = 50; Assert.AreEqual(50, item.MaxPercentage); } [Test()] public void EqualPercentLimitsDoesntFail() { UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MaxPercentage = 50; item.MinPercentage = 50; item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType()); item.MinPercentage = 50; item.MaxPercentage = 50; } } }