Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
comparison API/Objects/UnitTypeTest.cs @ 238:e173c5512067
* Update to v2.6 of NUnit and new syntax/API changes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 28 Apr 2013 19:32:38 +0100 |
parents | d60d93b787dc |
children |
comparison
equal
deleted
inserted
replaced
237:833f72be715a | 238:e173c5512067 |
---|---|
2 // | 2 // |
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 IBBoard.WarFoundry.API.Objects.Mock; | 4 using IBBoard.WarFoundry.API.Objects.Mock; |
5 using NUnit.Framework; | 5 using NUnit.Framework; |
6 using NUnit.Framework.Constraints; | 6 using NUnit.Framework.Constraints; |
7 using NUnit.Framework.SyntaxHelpers; | |
8 using IBBoard.WarFoundry.API.Objects.Requirement; | 7 using IBBoard.WarFoundry.API.Objects.Requirement; |
9 using System.Reflection; | 8 using System.Reflection; |
10 using IBBoard.NUnit; | 9 using IBBoard.NUnit; |
11 using IBBoard.WarFoundry.API.Factories; | 10 using IBBoard.WarFoundry.API.Factories; |
12 | 11 |
52 [Test] | 51 [Test] |
53 public void TestAddingRequirementsToUnitType() | 52 public void TestAddingRequirementsToUnitType() |
54 { | 53 { |
55 UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace()); | 54 UnitType unitType = new UnitType("unittype1", "Swordsmen", new MockRace()); |
56 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType); | 55 UnitRequiresAtLeastNUnitsRequirement req = new UnitRequiresAtLeastNUnitsRequirement(unitType); |
57 Assert.That(unitType.GetRequirements(), Has.Length(0)); | 56 Assert.That(unitType.GetRequirements(), Has.Length.EqualTo(0)); |
58 unitType.AddRequirement(req); | 57 unitType.AddRequirement(req); |
59 Assert.That(unitType.GetRequirements(), Has.Length(1)); | 58 Assert.That(unitType.GetRequirements(), Has.Length.EqualTo(1)); |
60 } | 59 } |
61 | 60 |
62 [Test] | 61 [Test] |
63 public void TestGetRequirementsGetsUnitCountRequirements() | 62 public void TestGetRequirementsGetsUnitCountRequirements() |
64 { | 63 { |
65 MockRace mockRace = new MockRace(); | 64 MockRace mockRace = new MockRace(); |
66 UnitType unitType = new UnitType("unittype1", "Swordsmen", mockRace); | 65 UnitType unitType = new UnitType("unittype1", "Swordsmen", mockRace); |
67 unitType.MinNumber = 1; | 66 unitType.MinNumber = 1; |
68 unitType.MaxNumber = 2; | 67 unitType.MaxNumber = 2; |
69 Assert.That(unitType.GetRequirements(), Has.Length(2)); | 68 Assert.That(unitType.GetRequirements(), Has.Length.EqualTo(2)); |
70 RaceRequiresNoMoreThanNUnitsRequirement maxLimit = new RaceRequiresNoMoreThanNUnitsRequirement(mockRace); | 69 RaceRequiresNoMoreThanNUnitsRequirement maxLimit = new RaceRequiresNoMoreThanNUnitsRequirement(mockRace); |
71 maxLimit.AddUnitTypeRequirement(unitType, 2); | 70 maxLimit.AddUnitTypeRequirement(unitType, 2); |
72 Assert.That(unitType.GetRequirements(), Has.Member(maxLimit)); | 71 Assert.That(unitType.GetRequirements(), Has.Member(maxLimit)); |
73 RaceRequiresAtLeastNUnitsRequirement minLimit = new RaceRequiresAtLeastNUnitsRequirement(mockRace); | 72 RaceRequiresAtLeastNUnitsRequirement minLimit = new RaceRequiresAtLeastNUnitsRequirement(mockRace); |
74 minLimit.AddUnitTypeRequirement(unitType, 1); | 73 minLimit.AddUnitTypeRequirement(unitType, 1); |