comparison API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs @ 217:9bf34e88da89

Re #379: Fix validation of requirements to check for unit * Add equality tests to try to resolve UnitType tests for limits as requirements * Ensure consistency with extra layer in hierarchy
author IBBoard <dev@ibboard.co.uk>
date Mon, 05 Mar 2012 20:34:45 +0000
parents 1674a499168e
children f951595143a9
comparison
equal deleted inserted replaced
216:442bcf7306b9 217:9bf34e88da89
7 using NUnit.Framework.SyntaxHelpers; 7 using NUnit.Framework.SyntaxHelpers;
8 8
9 namespace IBBoard.WarFoundry.API.Objects.Requirement 9 namespace IBBoard.WarFoundry.API.Objects.Requirement
10 { 10 {
11 [TestFixture()] 11 [TestFixture()]
12 public class UnitRequiresNUnitsForMUnitsRequirementTests : AbstractUnitRequirementTest<UnitType> 12 public class UnitRequiresNUnitsForMUnitsRequirementTests : AbstractUnitTypeUnitRequirementTest<UnitType, UnitRequiresNUnitsForMUnitsRequirement>
13 { 13 {
14 private MockRace mockRace;
15 private UnitType unitType1;
16 private UnitType unitType2;
17 private UnitType unitType3;
18
19 [TestFixtureSetUp()]
20 public void SetupRace()
21 {
22 mockRace = new MockRace();
23 unitType1 = new MockUnitType("type1", "Unit Type 1");
24 mockRace.AddUnitType(unitType1);
25 unitType2 = new MockUnitType("type2", "Unit Type 2");
26 mockRace.AddUnitType(unitType2);
27 unitType3 = new MockUnitType("type3", "Unit Type 3");
28 mockRace.AddUnitType(unitType3);
29 }
30
31 [Test()] 14 [Test()]
32 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredFails() 15 public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredFails()
33 { 16 {
34 Army army = new Army(mockRace, "Test", 1000); 17 Army army = new Army(mockRace, "Test", 1000);
35 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); 18 UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1);
307 req.AddUnitTypeRequirement(unitType2); 290 req.AddUnitTypeRequirement(unitType2);
308 Assert_That__ValidationPasses(req, army); 291 Assert_That__ValidationPasses(req, army);
309 AddUnitOfTypeToArmy(unitType1, army); 292 AddUnitOfTypeToArmy(unitType1, army);
310 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."); 293 Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2).");
311 } 294 }
295
296 protected override UnitRequiresNUnitsForMUnitsRequirement CreateRequirement(UnitType requirementOn)
297 {
298 return new UnitRequiresNUnitsForMUnitsRequirement(requirementOn);
299 }
312 } 300 }
313 } 301 }
314 302