annotate API/Objects/UnitEquipmentNumericSelectionTests.cs @ 239:370bec16a364 default tip

Add initial testing for equipment with type (incomplete)
author IBBoard <dev@ibboard.co.uk>
date Sun, 16 Oct 2016 20:29:35 +0100
parents e173c5512067
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
184
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitEquipmentRatioSelectionTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // 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.
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Util;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using IBBoard.WarFoundry.API.Factories;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.Limits;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 namespace IBBoard.WarFoundry.API.Objects
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 [TestFixture()]
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 public class UnitEquipmentNumericSelectionTests
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 {
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 [Test()]
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 public void Bug366TestAmountIsNotLimitedByRatioAmount()
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 {
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 DummyWarFoundryFactory factory = new DummyWarFoundryFactory();
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 Race race = new Race("race", "Race", new GameSystem("gs", "System", factory), factory);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 Category cat = new Category("cat1", "Category");
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 race.AddCategory(cat);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 EquipmentItem equip1 = new EquipmentItem("equip1", "Equipment 1", race);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 race.AddEquipmentItem(equip1);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 EquipmentItem equip2 = new EquipmentItem("equip2", "Equipment 2", race);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 race.AddEquipmentItem(equip2);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 UnitType unitType = new UnitType("type1", "UnitType", race);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 unitType.AddEquipmentSlot("slot", new SimpleRoundedPercentageLimit(33, true));
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 UnitEquipmentItem unitEquip1 = new UnitEquipmentItem(equip1, unitType);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 unitEquip1.SlotName = "slot";
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 unitEquip1.RoundNumberUp = true;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 unitEquip1.MinLimit = new SimpleRoundedPercentageLimit(0);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 unitEquip1.MaxLimit = new SimpleRoundedPercentageLimit(33, true);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 UnitEquipmentItem unitEquip2 = new UnitEquipmentItem(equip2, unitType);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 unitEquip2.SlotName = "slot";
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 unitEquip2.RoundNumberUp = true;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 unitEquip2.MinLimit = new SimpleRoundedPercentageLimit(0);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 unitEquip2.MaxLimit = new SimpleRoundedPercentageLimit(33, true);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 race.AddUnitType(unitType);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 Army army = new Army(race, "army", 1000);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 Unit unit = new Unit(unitType, army.GetCategory(cat));
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 unit.Size = 3;
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 unit.SetEquipmentAmount(unitEquip2, 1);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 unit.SetEquipmentRatio(unitEquip1, 33);
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 Assert.That(UnitEquipmentUtil.GetEquipmentAmount(unit, unitEquip2), Is.EqualTo(1));
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 Assert.That(UnitEquipmentUtil.GetEquipmentAmountTaken(unit, unitEquip2), Is.EqualTo(1));
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 Assert.That(unit.GetEquipmentAmountInSlot("slot"), Is.EqualTo(2));
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 }
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 }
00ea622313be Re #366: Rewrite equipment handling and limits
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50