Mercurial > repos > IBBoard.Tests
annotate Limits/AbstractCompositeLimitTest.cs @ 28:31fdc90f3556
* Fix license comments at top of files
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Aug 2010 10:07:09 +0000 |
parents | 57b5d27e95fb |
children | 99e4c1949c92 |
rev | line source |
---|---|
26 | 1 // This file (AbstractCompositeLimitTest.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard |
2 // | |
28
31fdc90f3556
* Fix license comments at top of files
IBBoard <dev@ibboard.co.uk>
parents:
26
diff
changeset
|
3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
26 | 4 using System.Collections.Generic; |
5 using NUnit.Framework; | |
6 using NUnit.Framework.SyntaxHelpers; | |
7 | |
8 namespace IBBoard.Limits | |
9 { | |
10 public abstract class AbstractCompositeLimitTest | |
11 { | |
12 [Test()] | |
13 public void TestCompositeWithZeroLimits() | |
14 { | |
15 Assert.That(CreateCompositeLimitWithCollection(new List<ILimit>()).GetLimit(100), Is.EqualTo(0)); | |
16 } | |
17 | |
18 [Test()] | |
19 public void TestCompositeWithOneLimitReturnsLimitValue() | |
20 { | |
21 NumericSizeConstrainedLimit limit = new NumericSizeConstrainedLimit(10); | |
22 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithLimit(limit); | |
23 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(limit.GetLimit(1))); | |
24 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(limit.GetLimit(10))); | |
25 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(limit.GetLimit(100))); | |
26 } | |
27 | |
28 [Test()] | |
29 public void TestCompositeWithMultipleLimitsReturnsCorrectValues() | |
30 { | |
31 List<ILimit> limits = new List<ILimit>(); | |
32 int sizeConstrainedLimitNum = 10; | |
33 NumericSizeConstrainedLimit limit1 = new NumericSizeConstrainedLimit(sizeConstrainedLimitNum); | |
34 limits.Add(limit1); | |
35 int absoluteLimitNum = 5; | |
36 AbsoluteNumericLimit limit2 = new AbsoluteNumericLimit(absoluteLimitNum); | |
37 limits.Add(limit2); | |
38 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithCollection(limits); | |
39 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(GetMultipleLimitValue(1, sizeConstrainedLimitNum, absoluteLimitNum))); | |
40 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(GetMultipleLimitValue(10, sizeConstrainedLimitNum, absoluteLimitNum))); | |
41 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(GetMultipleLimitValue(100, sizeConstrainedLimitNum, absoluteLimitNum))); | |
42 } | |
43 | |
44 protected abstract AbstractCompositeLimit CreateCompositeLimitWithLimit(ILimit limit); | |
45 protected abstract AbstractCompositeLimit CreateCompositeLimitWithCollection(List<ILimit> limits); | |
46 protected abstract int GetMultipleLimitValue(int numberBeingLimited, int sizeConstrainedLimitNum, int absoluteLimitNum); | |
47 } | |
48 } | |
49 |