changeset 135:8c3bba80a25e

Re #27: Unit requirements * Add tests for mixed requirements * Add tests for adding units
author IBBoard <dev@ibboard.co.uk>
date Mon, 25 Apr 2011 10:31:49 +0000
parents 4e1a477c38d8
children d28c3c1ec1ec
files API/Objects/Requirement/RequirementHandlerTests.cs
diffstat 1 files changed, 113 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequirementHandlerTests.cs	Fri Apr 22 10:30:26 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequirementHandlerTests.cs	Mon Apr 25 10:31:49 2011 +0000
     1.3 @@ -53,6 +53,119 @@
     1.4  			Army army = new Army(race, "test", 1000);
     1.5  			Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Passed));
     1.6  		}
     1.7 +
     1.8 +		[Test()]
     1.9 +		public void TestArmyWithMixedRequirementsWithFailFails()
    1.10 +		{
    1.11 +			MockRace race = new MockRace();
    1.12 +			MockUnitType mockUnitType = new MockUnitType();
    1.13 +			mockUnitType.AddRequirement(new PassingRequirement());
    1.14 +			mockUnitType.AddRequirement(new FailingRequirement());
    1.15 +			race.AddUnitType(mockUnitType);
    1.16 +			Army army = new Army(race, "test", 1000);
    1.17 +			Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Failed));
    1.18 +		}
    1.19 +
    1.20 +		[Test()]
    1.21 +		public void TestArmyWithMixedRequirementsWithFailInOtherOrderFails()
    1.22 +		{
    1.23 +			MockRace race = new MockRace();
    1.24 +			MockUnitType mockUnitType = new MockUnitType();
    1.25 +			mockUnitType.AddRequirement(new FailingRequirement());
    1.26 +			mockUnitType.AddRequirement(new PassingRequirement());
    1.27 +			race.AddUnitType(mockUnitType);
    1.28 +			Army army = new Army(race, "test", 1000);
    1.29 +			Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Failed));
    1.30 +		}
    1.31 +
    1.32 +		[Test()]
    1.33 +		public void TestArmyWithMixedRequirementsWithNoFailsPasses()
    1.34 +		{
    1.35 +			MockRace race = new MockRace();
    1.36 +			MockUnitType mockUnitType = new MockUnitType();
    1.37 +			mockUnitType.AddRequirement(new PassingRequirement());
    1.38 +			mockUnitType.AddRequirement(new NotApplicableRequirement());
    1.39 +			race.AddUnitType(mockUnitType);
    1.40 +			Army army = new Army(race, "test", 1000);
    1.41 +			Assert.That(RequirementHandler.ValidateArmy(army), Is.EqualTo(Validation.Passed));
    1.42 +		}
    1.43 +
    1.44 +		[Test()]
    1.45 +		public void TestCanAddToArmyWithNoRequirementsValidates()
    1.46 +		{
    1.47 +			MockRace race = new MockRace();
    1.48 +			Army army = new Army(race, "test", 1000);
    1.49 +			Assert.That(RequirementHandler.AllowsAdding(new MockUnitType(), army), Is.EqualTo(Validation.Passed));
    1.50 +		}
    1.51 +
    1.52 +		[Test()]
    1.53 +		public void TestCanAddToArmyWithFailingRequirementFails()
    1.54 +		{
    1.55 +			MockRace race = new MockRace();
    1.56 +			MockUnitType mockUnitType = new MockUnitType();
    1.57 +			mockUnitType.AddRequirement(new FailingRequirement());
    1.58 +			race.AddUnitType(mockUnitType);
    1.59 +			Army army = new Army(race, "test", 1000);
    1.60 +			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Failed));
    1.61 +		}
    1.62 +
    1.63 +		[Test()]
    1.64 +		public void TestCanAddToArmyWithPassingRequirementPasses()
    1.65 +		{
    1.66 +			MockRace race = new MockRace();
    1.67 +			MockUnitType mockUnitType = new MockUnitType();
    1.68 +			mockUnitType.AddRequirement(new PassingRequirement());
    1.69 +			race.AddUnitType(mockUnitType);
    1.70 +			Army army = new Army(race, "test", 1000);
    1.71 +			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
    1.72 +		}
    1.73 +
    1.74 +		[Test()]
    1.75 +		public void TestCanAddToArmyWithNotApplicableRequirementPasses()
    1.76 +		{
    1.77 +			MockRace race = new MockRace();
    1.78 +			MockUnitType mockUnitType = new MockUnitType();
    1.79 +			mockUnitType.AddRequirement(new NotApplicableRequirement());
    1.80 +			race.AddUnitType(mockUnitType);
    1.81 +			Army army = new Army(race, "test", 1000);
    1.82 +			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
    1.83 +		}
    1.84 +
    1.85 +		[Test()]
    1.86 +		public void TestCanAddToArmyWithMixedRequirementsWithFailFails()
    1.87 +		{
    1.88 +			MockRace race = new MockRace();
    1.89 +			MockUnitType mockUnitType = new MockUnitType();
    1.90 +			mockUnitType.AddRequirement(new PassingRequirement());
    1.91 +			mockUnitType.AddRequirement(new FailingRequirement());
    1.92 +			race.AddUnitType(mockUnitType);
    1.93 +			Army army = new Army(race, "test", 1000);
    1.94 +			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Failed));
    1.95 +		}
    1.96 +
    1.97 +		[Test()]
    1.98 +		public void TestCanAddToArmyWithMixedRequirementsWithFailInOtherOrderFails()
    1.99 +		{
   1.100 +			MockRace race = new MockRace();
   1.101 +			MockUnitType mockUnitType = new MockUnitType();
   1.102 +			mockUnitType.AddRequirement(new FailingRequirement());
   1.103 +			mockUnitType.AddRequirement(new PassingRequirement());
   1.104 +			race.AddUnitType(mockUnitType);
   1.105 +			Army army = new Army(race, "test", 1000);
   1.106 +			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Failed));
   1.107 +		}
   1.108 +
   1.109 +		[Test()]
   1.110 +		public void TestCanAddToArmyWithMixedRequirementsWithNoFailsPasses()
   1.111 +		{
   1.112 +			MockRace race = new MockRace();
   1.113 +			MockUnitType mockUnitType = new MockUnitType();
   1.114 +			mockUnitType.AddRequirement(new PassingRequirement());
   1.115 +			mockUnitType.AddRequirement(new NotApplicableRequirement());
   1.116 +			race.AddUnitType(mockUnitType);
   1.117 +			Army army = new Army(race, "test", 1000);
   1.118 +			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
   1.119 +		}
   1.120  	}
   1.121  }
   1.122