Mercurial > repos > IBBoard.WarFoundry.API.Tests
comparison API/Objects/Requirement/AbstractUnitRequirementTest.cs @ 231:5e03b68dd214
Re #410: Create "N units per M models in parent unit" requirement
* Add required usage of context objects
* Add tests for new requirement
* Add some extras to test unit type setup that the new requirement needs
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 27 Jul 2012 20:33:40 +0100 |
parents | f951595143a9 |
children | 99248d05ba9c |
comparison
equal
deleted
inserted
replaced
230:d6883a522c70 | 231:5e03b68dd214 |
---|---|
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. | 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. |
4 using System; | 4 using System; |
5 using NUnit.Framework; | 5 using NUnit.Framework; |
6 using NUnit.Framework.SyntaxHelpers; | 6 using NUnit.Framework.SyntaxHelpers; |
7 using IBBoard.NUnit; | 7 using IBBoard.NUnit; |
8 using System.Collections.Generic; | |
8 | 9 |
9 namespace IBBoard.WarFoundry.API.Objects.Requirement | 10 namespace IBBoard.WarFoundry.API.Objects.Requirement |
10 { | 11 { |
11 /// <summary> | 12 /// <summary> |
12 /// Base class of helper methods for checking unit requirements | 13 /// Base class of helper methods for checking unit requirements |
56 { | 57 { |
57 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); | 58 Assert.That(req.ValidatesArmy(army), Is.EqualTo(Validation.Failed)); |
58 Assert.That(req.GetValidationMessage(army), Is.EqualTo(message)); | 59 Assert.That(req.GetValidationMessage(army), Is.EqualTo(message)); |
59 } | 60 } |
60 | 61 |
61 protected static void AddUnitsOfTypeToArmy(int count, UnitType unitType, Army army) | 62 protected static ICollection<Unit> AddUnitsOfTypeToArmy(int count, UnitType unitType, Army army) |
62 { | 63 { |
64 ICollection<Unit> units = new List<Unit>(); | |
65 | |
63 for (int i = 0; i < count; i++) | 66 for (int i = 0; i < count; i++) |
64 { | 67 { |
65 AddUnitOfTypeToArmy(unitType, army); | 68 units.Add(AddUnitOfTypeToArmy(unitType, army)); |
66 } | 69 } |
70 | |
71 return units; | |
67 } | 72 } |
68 | 73 |
69 protected static void AddUnitOfTypeToArmy(UnitType unitType, Army army) | 74 protected static Unit AddUnitOfTypeToArmy(UnitType unitType, Army army) |
70 { | 75 { |
71 army.AddUnit(CreateUnitOfType(unitType, army)); | 76 Unit unit = CreateUnitOfType(unitType, army); |
77 army.AddUnit(unit); | |
78 return unit; | |
72 } | 79 } |
73 | 80 |
74 protected static Unit CreateUnitOfType(UnitType unitType, Army army) | 81 protected static Unit CreateUnitOfType(UnitType unitType, Army army) |
75 { | 82 { |
76 return new Unit(unitType, army.GetCategory(unitType.MainCategory)); | 83 return new Unit(unitType, army.GetCategory(unitType.MainCategory)); |