changeset 143:6fdb76d48e04

Re #345: Add failure message to requirements * Test return of messages from requirement handler
author IBBoard <dev@ibboard.co.uk>
date Sun, 01 May 2011 14:45:22 +0000
parents f36b5e5e51e6
children eced294e82f2
files API/Objects/Requirement/RequirementHandlerTests.cs
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/API/Objects/Requirement/RequirementHandlerTests.cs	Sun May 01 14:32:24 2011 +0000
     1.2 +++ b/API/Objects/Requirement/RequirementHandlerTests.cs	Sun May 01 14:45:22 2011 +0000
     1.3 @@ -7,6 +7,7 @@
     1.4  using IBBoard.WarFoundry.API.Objects;
     1.5  using NUnit.Framework.SyntaxHelpers;
     1.6  using IBBoard.WarFoundry.API.Objects.Requirement.Mock;
     1.7 +using System.Collections.Generic;
     1.8  
     1.9  namespace IBBoard.WarFoundry.API.Objects.Requirement
    1.10  {
    1.11 @@ -166,6 +167,22 @@
    1.12  			Army army = new Army(race, "test", 1000);
    1.13  			Assert.That(RequirementHandler.AllowsAdding(mockUnitType, army), Is.EqualTo(Validation.Passed));
    1.14  		}
    1.15 +
    1.16 +		[Test()]
    1.17 +		public void TestArmyWithMixedRequirementsGetsExpectedFailureMessageCount()
    1.18 +		{
    1.19 +			MockRace race = new MockRace();
    1.20 +			MockUnitType mockUnitType = new MockUnitType();
    1.21 +			mockUnitType.AddRequirement(new PassingRequirement());
    1.22 +			mockUnitType.AddRequirement(new NotApplicableRequirement());
    1.23 +			mockUnitType.AddRequirement(new FailingRequirement());
    1.24 +			mockUnitType.AddRequirement(new FailingRequirement());
    1.25 +			race.AddUnitType(mockUnitType);
    1.26 +			Army army = new Army(race, "test", 1000);
    1.27 +			ICollection<string> failureMessages;
    1.28 +			RequirementHandler.ValidateArmy(army, out failureMessages);
    1.29 +			Assert.That(failureMessages, Has.Count(2));
    1.30 +		}
    1.31  	}
    1.32  }
    1.33