annotate API/Factories/Requirement/UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs @ 150:b86955aa252c

Re #351: Add extensible requirement handling method * Start testing requirement factory
author IBBoard <dev@ibboard.co.uk>
date Mon, 13 Jun 2011 20:04:40 +0000
parents
children 60de02ce78d8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (UnitRequiresAtLeastNUnitsRequirementFactoryTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 //
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 // 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.
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using IBBoard.WarFoundry.API.Objects.Mock;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 using NUnit.Framework.SyntaxHelpers;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 using IBBoard.WarFoundry.API.Objects;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 using IBBoard.WarFoundry.API.Objects.Requirement;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 namespace IBBoard.WarFoundry.API.Factories.Requirement
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 [TestFixture()]
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public class UnitRequiresAtLeastNUnitsRequirementFactoryTest
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 private static Race race;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 private static string typeID = "unit1";
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 private UnitType unitType1;
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 [TestFixtureSetUp()]
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 public void Setup()
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 {
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 race = new MockRace();
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 unitType1 = new UnitType(typeID, "Unit 1", race);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 race.AddUnitType(unitType1);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 }
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 [Test()]
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 public void TestCreatesRequirement()
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 {
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory();
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 Assert.That(factory.CreateRequirement(new MockUnitType(), typeID), Is.Not.Null);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 }
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 [Test()]
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 public void TestCreatesCorrectRequirement()
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 {
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 UnitRequiresAtLeastNUnitsRequirementFactory factory = new UnitRequiresAtLeastNUnitsRequirementFactory();
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 UnitType unitType = new UnitType("unit2", "Unit 2", race);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 UnitRequiresAtLeastNUnitsRequirement expectedReq = new UnitRequiresAtLeastNUnitsRequirement(unitType);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 expectedReq.AddUnitTypeRequirement(unitType1);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 UnitRequiresAtLeastNUnitsRequirement req = factory.CreateRequirement(unitType, typeID);
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 Assert.That(req, Is.EqualTo(expectedReq));
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 }
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 }
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 }
b86955aa252c Re #351: Add extensible requirement handling method
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47