comparison API/Objects/UnitEquipmentItemTest.cs @ 12:a4e7e938d065

Re #195: Setting max equipment without min may not function correctly * Initial commit of tests for limits (percentage and numeric) Also: * Reshuffle and refactoring of existing tests * Additional mocks required by the new tests
author IBBoard <dev@ibboard.co.uk>
date Mon, 12 Oct 2009 19:42:30 +0000
parents
children ca5d7c2c7493
comparison
equal deleted inserted replaced
11:8d9d49332d44 12:a4e7e938d065
1 // This file (UnitEquipmentItemTests.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 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
5 using System;
6 using NUnit.Framework;
7 using IBBoard.WarFoundry.API.Objects.Mock;
8
9 namespace IBBoard.WarFoundry.API.Objects
10 {
11 [TestFixture()]
12 public class UnitEquipmentItemTest
13 {
14 [Test()]
15 public void DefaultMinMaxNumberLimitsAreZero()
16 {
17 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
18 Assert.AreEqual(0, item.MinNumber);
19 Assert.AreEqual(0, item.MaxNumber);
20 }
21
22 [Test()]
23 public void MinNumberLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
24 {
25 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
26 item.MaxNumber = 1;
27 Assert.AreEqual(1, item.MinNumber);
28 }
29
30 [Test()]
31 public void MinNumberLimitUntouchedWhenSetFirst()
32 {
33 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
34 item.MinNumber = 1;
35 item.MaxNumber = 10;
36 Assert.AreEqual(1, item.MinNumber);
37 }
38
39 [Test()]
40 public void MinNumberLimitSetToMaxWhenMaxLessThanMin()
41 {
42 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
43 item.MinNumber = 10;
44 item.MaxNumber = 1;
45 Assert.AreEqual(1, item.MinNumber);
46 }
47
48 [Test()]
49 public void MaxNumberLimitSetToMinWhenMinGreaterThanMax()
50 {
51 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
52 item.MaxNumber = 1;
53 item.MinNumber = 10;
54 Assert.AreEqual(10, item.MaxNumber);
55 }
56
57 [Test()]
58 public void EqualNumberLimitsDoesntFail()
59 {
60 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
61 item.MaxNumber = 10;
62 item.MinNumber = 10;
63 item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
64 item.MinNumber = 10;
65 item.MaxNumber = 10;
66 }
67
68 [Test()]
69 public void DefaultMinMaxPercentageLimitsAreZero()
70 {
71 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
72 Assert.AreEqual(0, item.MinPercentage);
73 Assert.AreEqual(0, item.MaxPercentage);
74 }
75
76 [Test()]
77 public void MinPercentLimitEqualsMaxLimitWhenOnlyMaxLimitSet()
78 {
79 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
80 item.MaxPercentage = 50;
81 Assert.AreEqual(50, item.MinPercentage);
82 }
83
84 [Test()]
85 public void MinPercentLimitUntouchedWhenSetFirst()
86 {
87 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
88 item.MinPercentage = 25;
89 item.MaxPercentage = 50;
90 Assert.AreEqual(25, item.MinPercentage);
91 }
92
93 [Test()]
94 public void MinPercentLimitSetToMaxWhenMaxLessThanMin()
95 {
96 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
97 item.MinNumber = 50;
98 item.MaxPercentage = 25;
99 Assert.AreEqual(25, item.MinPercentage);
100 }
101
102 [Test()]
103 public void MaxPercentLimitSetToMinWhenMinGreaterThanMax()
104 {
105 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
106 item.MaxPercentage = 25;
107 item.MinPercentage = 50;
108 Assert.AreEqual(50, item.MaxPercentage);
109 }
110
111 [Test()]
112 public void EqualPercentLimitsDoesntFail()
113 {
114 UnitEquipmentItem item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
115 item.MaxPercentage = 50;
116 item.MinPercentage = 50;
117 item = new UnitEquipmentItem(new MockEquipmentItem(), new MockUnitType());
118 item.MinPercentage = 50;
119 item.MaxPercentage = 50;
120 }
121 }
122 }