Mercurial > repos > IBBoard.WarFoundry.API.Tests
comparison API/Objects/Requirement/UnitCountRequirementDataTest.cs @ 137:081b48413f6d
Re #140: Add equality methods to WarFoundry objects
* Add equality to Race, GameSystem and UnitType tests
* Create equality test for UnitCountRequirementData
Not all tests pass yet
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 26 Apr 2011 15:03:46 +0000 |
parents | |
children | 2ae80631ec9c |
comparison
equal
deleted
inserted
replaced
136:d28c3c1ec1ec | 137:081b48413f6d |
---|---|
1 // This file (UnitCountRequirementDataTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2011 IBBoard | |
2 // | |
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. | |
4 using System; | |
5 using NUnit.Framework; | |
6 using IBBoard.NUnit; | |
7 using IBBoard.WarFoundry.API.Objects.Mock; | |
8 using IBBoard.WarFoundry.API.Factories; | |
9 using System.Reflection; | |
10 | |
11 namespace IBBoard.WarFoundry.API.Objects.Requirement | |
12 { | |
13 [TestFixture()] | |
14 public class UnitCountRequirementDataTest : AbstractEqualityTest<UnitCountRequirementData> | |
15 { | |
16 //FIXME We shouldn't duplicate these tests, but it is broken at the moment | |
17 [Test] | |
18 public void TestEquality() | |
19 { | |
20 Assert.AreEqual(GetObject(), GetSameObject()); | |
21 Assert.AreEqual(GetSameObject(), GetObject()); | |
22 } | |
23 | |
24 [Test] | |
25 public void TestInequality() | |
26 { | |
27 Assert.AreNotEqual(GetObject(), GetDifferentObject()); | |
28 Assert.AreNotEqual(GetSameObject(), GetDifferentObject()); | |
29 Assert.AreNotEqual(GetDifferentObject(), GetObject()); | |
30 Assert.AreNotEqual(GetDifferentObject(), GetSameObject()); | |
31 } | |
32 | |
33 [Test] | |
34 public void TestReflexiveEquality() | |
35 { | |
36 Assert.AreEqual(GetObject(), GetObject()); | |
37 Assert.AreEqual(GetSameObject(), GetSameObject()); | |
38 Assert.AreEqual(GetDifferentObject(), GetDifferentObject()); | |
39 } | |
40 | |
41 [Test] | |
42 public void TestOtherInequality() | |
43 { | |
44 MethodInfo[] methodInfo = GetType().GetMethods(); | |
45 UnitCountRequirementData obj = GetObject(); | |
46 | |
47 foreach (MethodInfo method in methodInfo) | |
48 { | |
49 if (method.Name.StartsWith("GetOtherDifferent")) | |
50 { | |
51 UnitCountRequirementData otherObj = (UnitCountRequirementData)method.Invoke(this, new object[0]); | |
52 Assert.AreNotEqual(obj, otherObj, "Objects equal for "+method.Name); | |
53 Assert.AreNotEqual(otherObj, obj, "Objects equal for "+method.Name); | |
54 } | |
55 } | |
56 } | |
57 | |
58 | |
59 | |
60 public override UnitCountRequirementData GetObject () | |
61 { | |
62 return new UnitCountRequirementData(new MockUnitType(), 1); | |
63 } | |
64 | |
65 public override UnitCountRequirementData GetSameObject () | |
66 { | |
67 return new UnitCountRequirementData(new MockUnitType(), 1); | |
68 } | |
69 | |
70 public override UnitCountRequirementData GetDifferentObject () | |
71 { | |
72 DummyWarFoundryFactory factory = new DummyWarFoundryFactory(); | |
73 GameSystem gameSystem = new GameSystem("system", "system", factory); | |
74 Race race = new Race("race", "race", gameSystem, factory); | |
75 return new UnitCountRequirementData(new UnitType("id9", "some name", race), 2); | |
76 } | |
77 } | |
78 } | |
79 |