Mercurial > repos > IBBoard.Tests
annotate Limits/AbstractCompositeLimitTest.cs @ 49:99e4c1949c92 default tip
* Update to v2.6 of NUnit and new syntax/API changes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 28 Apr 2013 19:32:14 +0100 |
parents | 31fdc90f3556 |
children |
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 | |
7 namespace IBBoard.Limits | |
8 { | |
9 public abstract class AbstractCompositeLimitTest | |
10 { | |
11 [Test()] | |
12 public void TestCompositeWithZeroLimits() | |
13 { | |
14 Assert.That(CreateCompositeLimitWithCollection(new List<ILimit>()).GetLimit(100), Is.EqualTo(0)); | |
15 } | |
16 | |
17 [Test()] | |
18 public void TestCompositeWithOneLimitReturnsLimitValue() | |
19 { | |
20 NumericSizeConstrainedLimit limit = new NumericSizeConstrainedLimit(10); | |
21 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithLimit(limit); | |
22 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(limit.GetLimit(1))); | |
23 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(limit.GetLimit(10))); | |
24 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(limit.GetLimit(100))); | |
25 } | |
26 | |
27 [Test()] | |
28 public void TestCompositeWithMultipleLimitsReturnsCorrectValues() | |
29 { | |
30 List<ILimit> limits = new List<ILimit>(); | |
31 int sizeConstrainedLimitNum = 10; | |
32 NumericSizeConstrainedLimit limit1 = new NumericSizeConstrainedLimit(sizeConstrainedLimitNum); | |
33 limits.Add(limit1); | |
34 int absoluteLimitNum = 5; | |
35 AbsoluteNumericLimit limit2 = new AbsoluteNumericLimit(absoluteLimitNum); | |
36 limits.Add(limit2); | |
37 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithCollection(limits); | |
38 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(GetMultipleLimitValue(1, sizeConstrainedLimitNum, absoluteLimitNum))); | |
39 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(GetMultipleLimitValue(10, sizeConstrainedLimitNum, absoluteLimitNum))); | |
40 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(GetMultipleLimitValue(100, sizeConstrainedLimitNum, absoluteLimitNum))); | |
41 } | |
42 | |
43 protected abstract AbstractCompositeLimit CreateCompositeLimitWithLimit(ILimit limit); | |
44 protected abstract AbstractCompositeLimit CreateCompositeLimitWithCollection(List<ILimit> limits); | |
45 protected abstract int GetMultipleLimitValue(int numberBeingLimited, int sizeConstrainedLimitNum, int absoluteLimitNum); | |
46 } | |
47 } | |
48 |