Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
view API/Objects/ArmyTests.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 | d39682a98adf |
children |
line wrap: on
line source
// This file (ArmyTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2012 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.Requirement.Mock; using System.Collections.Generic; using IBBoard.WarFoundry.API.Objects.Requirement; using IBBoard.WarFoundry.API.Objects.Mock; namespace IBBoard.WarFoundry.API.Objects { [TestFixture()] public class ArmyTests { private MockRace mockRace; private UnitType unitType1; private IRequirement unitType1Requirement; private UnitType unitType2; private IRequirement unitType2Requirement; private UnitType unitType3; private IRequirement unitType3Requirement; [TestFixtureSetUp()] public void SetupRace() { mockRace = new MockRace(); unitType1 = new MockUnitType("type1", "Unit Type 1"); mockRace.AddUnitType(unitType1); unitType1Requirement = new PassingRequirement(); unitType1.AddRequirement(unitType1Requirement); unitType2 = new MockUnitType("type2", "Unit Type 2"); mockRace.AddUnitType(unitType2); unitType2Requirement = new FailingRequirement(); unitType2.AddRequirement(unitType2Requirement); unitType3 = new MockUnitType("type3", "Unit Type 3"); mockRace.AddUnitType(unitType3); unitType3Requirement = new NotApplicableRequirement(); unitType3.AddRequirement(unitType3Requirement); } [Test()] public void TestGetRequirementsGetsAllRaceRequirements() { Army army = new Army(mockRace, "Test", 1000); ICollection<IRequirement> requirements = army.GetRequirements(); Assert.That(requirements, Has.Count.EqualTo(3)); Assert.That(requirements, Has.Member(unitType1Requirement)); Assert.That(requirements, Has.Member(unitType2Requirement)); Assert.That(requirements, Has.Member(unitType3Requirement)); } [Test()] public void TestGetRequirementsGetsJustAddedUnitRequirementsWithEmptyArmy() { Army army = new Army(mockRace, "Test", 1000); ICollection<IRequirement> requirements = army.GetAddingUnitRequirements(unitType1); Assert.That(requirements, Has.Count.EqualTo(1)); Assert.That(requirements, Has.Member(unitType1Requirement)); } [Test()] public void TestGetRequirementsGetsAddedUnitRequirementsAndExistingUnitRequirements() { Army army = new Army(mockRace, "Test", 1000); army.AddUnit(new Unit(unitType1, army.GetCategory(unitType1.MainCategory))); ICollection<IRequirement> requirements = army.GetAddingUnitRequirements(unitType2); Assert.That(requirements, Has.Count.EqualTo(2)); Assert.That(requirements, Has.Member(unitType1Requirement)); Assert.That(requirements, Has.Member(unitType2Requirement)); } } }