Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
view API/Objects/Requirement/UnitRequiresNUnitsForMUnitsRequirementTests.cs @ 220:0fa634c6391b
Re #394: Make requirements (or factory) more closely match Rollcall methods
* Add matching unit tests for validation
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 24 Mar 2012 19:32:47 +0000 |
parents | f951595143a9 |
children | c40cb2048fc3 |
line wrap: on
line source
// This file (UnitRequiresNUnitsForMUnitsRequirementTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard // // 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. using System; using NUnit.Framework; using IBBoard.WarFoundry.API.Objects.Mock; using NUnit.Framework.SyntaxHelpers; namespace IBBoard.WarFoundry.API.Objects.Requirement { [TestFixture()] public class UnitRequiresNUnitsForMUnitsRequirementTests : AbstractUnitTypeUnitRequirementTest<UnitType, UnitRequiresNUnitsForMUnitsRequirement> { [Test()] public void TestAddingUnitTypeWithNoUnitsAndOneUnitTypeRequiredFails() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); } [Test()] public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredPasses() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__PassesAdding(req, unitType1, army); } [Test()] public void TestAddingUnitTypeWithOneUnitAndOneUnitTypeRequiredPassesWhenAddingRequiredUnitType() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__PassesAdding(req, unitType2, army); } [Test()] public void TestAddingUnitTypeSetsLimit() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); Assert_That__PassesAdding(req, unitType1, army); } [Test()] public void TestAddingUnitTypeSetsLimitForFailure() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."); } [Test()] public void TestAddingUnitTriggersPass() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__PassesAdding(req, unitType1, army); } [Test()] public void TestAddingLimitedUnitTriggersFailure() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__PassesAdding(req, unitType2, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."); } [Test()] public void TestAddingUnitTypeDefaultsToOne() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__PassesAdding(req, unitType1, army); } [Test] public void TestRequirementNotApplicableWhenCheckingAddForNonLimitedUnits() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__AddingNotApplicable(req, unitType3, army); Assert_That__AddingNotApplicable(req, unitType2, army); } [Test] public void TestRequirementNotApplicableAfterAddingLimitedUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__AddingNotApplicable(req, unitType3, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__AddingNotApplicable(req, unitType3, army); } [Test] public void TestRequirementNotApplicableBecomesPassAfterAddingLimitedUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__AddingNotApplicable(req, unitType2, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__PassesAdding(req, unitType2, army); } [Test] public void TestRequirementNotApplicableBecomesFailAfterAddingLimitedUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2, 1); Assert_That__AddingNotApplicable(req, unitType2, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 2 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 1)."); } [Test] public void TestRequirementFailsWhenLimitedUnitsChange() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__PassesAdding(req, unitType2, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__FailsAdding(req, unitType2, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 2)."); } [Test] public void TestAddingRequirementWithOR() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, unitType3); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__PassesAdding(req, unitType1, army); } [Test] public void TestAddingRequirementWithORWithOtherUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, unitType3); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__PassesAdding(req, unitType1, army); } [Test] public void TestAddingRequirementWithORWithLimit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, 1, unitType2, unitType3); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__PassesAdding(req, unitType1, army); } [Test] public void TestAddingRequirementWithORWithLimitWithOtherUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, 1, unitType2, unitType3); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType3, army); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 1)."); AddUnitOfTypeToArmy(unitType3, army); Assert_That__PassesAdding(req, unitType1, army); } [Test] public void TestAddingRequirementWithORWithLimitWithBothUnits() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, 1, unitType2, unitType3); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (would have 1 for 1)."); AddUnitOfTypeToArmy(unitType3, army); Assert_That__PassesAdding(req, unitType1, army); } [Test] public void TestAddingRequirementWithORBasedOnRollcall() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, unitType2, unitType3); AddUnitsOfTypeToArmy(3, unitType2, army); AddUnitsOfTypeToArmy(2, unitType3, army); AddUnitsOfTypeToArmy(9, unitType1, army); Assert_That__PassesAdding(req, unitType1, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (would have 5 for 11)."); } [Test] public void TestAddingRequirementWithoutORBasedOnRollcall() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, unitType2); req.AddUnitTypeRequirement(2, unitType3); AddUnitsOfTypeToArmy(3, unitType2, army); AddUnitsOfTypeToArmy(2, unitType3, army); AddUnitsOfTypeToArmy(3, unitType1, army); Assert_That__PassesAdding(req, unitType1, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__FailsAdding(req, unitType1, army, "Army must contain: 1 × " + unitType3.Name + " for every 2 × " + unitType1.Name + " (would have 2 for 5)."); } [Test] public void TestValidationNotApplicableWithNoLimitedUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__NotApplicable(req, army); AddUnitOfTypeToArmy(unitType3, army); Assert_That__NotApplicable(req, army); AddUnitOfTypeToArmy(unitType2, army); Assert_That__NotApplicable(req, army); } [Test()] public void TestValidatingWithNoUnitsAndOneUnitTypeRequiredFails() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); } [Test()] public void TestValidatingUnitWithOneUnitAndOneUnitTypeRequiredPasses() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__ValidationPasses(req, army); } [Test()] public void TestValidatingUnitTypeSetsLimit() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType2, army); AddUnitOfTypeToArmy(unitType1, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); Assert_That__ValidationPasses(req, army); } [Test()] public void TestValidatingUnitTypeSetsLimitForFailure() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); AddUnitOfTypeToArmy(unitType1, army); AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."); } [Test()] public void TestAddingUnitTriggersValidationPass() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 1); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationPasses(req, army); } [Test()] public void TestAddingLimitedUnitTriggersValidationFailure() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__ValidationPasses(req, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."); } [Test()] public void TestValidatingUnitTypeDefaultsToOne() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestValidationRequirementNotApplicableWhenCheckingForNonLimitedUnits() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); AddUnitOfTypeToArmy(unitType3, army); Assert_That__NotApplicable(req, army); AddUnitOfTypeToArmy(unitType2, army); Assert_That__NotApplicable(req, army); } [Test] public void TestValidationNotApplicableBecomesPassAfterAddingLimitedUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); AddUnitOfTypeToArmy(unitType2, army); Assert_That__NotApplicable(req, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestValidationRequirementNotApplicableBecomesFailAfterAddingLimitedUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, 2, 1); AddUnitOfTypeToArmy(unitType2, army); Assert_That__NotApplicable(req, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 1)."); } [Test] public void TestValidationRequirementFailsWhenLimitedUnitsChange() { Army army = new Army(mockRace, "Test", 1000); AddUnitOfTypeToArmy(unitType1, army); AddUnitOfTypeToArmy(unitType2, army); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2); Assert_That__ValidationPasses(req, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " for every 1 × " + unitType1.Name + " (have 1 for 2)."); } [Test] public void TestRequirementWithOR() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, unitType3); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestRequirementWithORWithOtherUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(unitType2, unitType3); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestRequirementWithORWithLimit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, 1, unitType2, unitType3); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestRequirementWithORWithLimitWithOtherUnit() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, 1, unitType2, unitType3); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType3, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 1)."); AddUnitOfTypeToArmy(unitType3, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestRequirementWithORWithLimitWithBothUnits() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, 1, unitType2, unitType3); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 0 for 1)."); AddUnitOfTypeToArmy(unitType2, army); Assert_That__ValidationFails(req, army, "Army must contain: 2 × " + unitType2.Name + " or " + unitType3.Name + " for every 1 × " + unitType1.Name + " (have 1 for 1)."); AddUnitOfTypeToArmy(unitType3, army); Assert_That__ValidationPasses(req, army); } [Test] public void TestRequirementWithORBasedOnRollcall() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, unitType2, unitType3); AddUnitsOfTypeToArmy(3, unitType2, army); AddUnitsOfTypeToArmy(2, unitType3, army); AddUnitsOfTypeToArmy(10, unitType1, army); Assert_That__ValidationPasses(req, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType2.Name + " or " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 5 for 11)."); } [Test] public void TestRequirementWithoutORBasedOnRollcall() { Army army = new Army(mockRace, "Test", 1000); UnitRequiresNUnitsForMUnitsRequirement req = new UnitRequiresNUnitsForMUnitsRequirement(unitType1); req.AddUnitTypeRequirement(2, unitType2); req.AddUnitTypeRequirement(2, unitType3); AddUnitsOfTypeToArmy(3, unitType2, army); AddUnitsOfTypeToArmy(2, unitType3, army); AddUnitsOfTypeToArmy(4, unitType1, army); Assert_That__ValidationPasses(req, army); AddUnitOfTypeToArmy(unitType1, army); Assert_That__ValidationFails(req, army, "Army must contain: 1 × " + unitType3.Name + " for every 2 × " + unitType1.Name + " (have 2 for 5)."); } protected override UnitRequiresNUnitsForMUnitsRequirement CreateRequirement(UnitType requirementOn) { return new UnitRequiresNUnitsForMUnitsRequirement(requirementOn); } } }