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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 // This file (AbstractCompositeLimitTest.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
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
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System.Collections.Generic;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using NUnit.Framework;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework.SyntaxHelpers;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 namespace IBBoard.Limits
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 public abstract class AbstractCompositeLimitTest
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 [Test()]
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 public void TestCompositeWithZeroLimits()
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 Assert.That(CreateCompositeLimitWithCollection(new List<ILimit>()).GetLimit(100), Is.EqualTo(0));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 }
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 [Test()]
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 public void TestCompositeWithOneLimitReturnsLimitValue()
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 NumericSizeConstrainedLimit limit = new NumericSizeConstrainedLimit(10);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithLimit(limit);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(limit.GetLimit(1)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(limit.GetLimit(10)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(limit.GetLimit(100)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 }
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 [Test()]
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 public void TestCompositeWithMultipleLimitsReturnsCorrectValues()
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 List<ILimit> limits = new List<ILimit>();
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 int sizeConstrainedLimitNum = 10;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 NumericSizeConstrainedLimit limit1 = new NumericSizeConstrainedLimit(sizeConstrainedLimitNum);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 limits.Add(limit1);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 int absoluteLimitNum = 5;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 AbsoluteNumericLimit limit2 = new AbsoluteNumericLimit(absoluteLimitNum);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 limits.Add(limit2);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithCollection(limits);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(GetMultipleLimitValue(1, sizeConstrainedLimitNum, absoluteLimitNum)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
40 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(GetMultipleLimitValue(10, sizeConstrainedLimitNum, absoluteLimitNum)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(GetMultipleLimitValue(100, sizeConstrainedLimitNum, absoluteLimitNum)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 }
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 protected abstract AbstractCompositeLimit CreateCompositeLimitWithLimit(ILimit limit);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 protected abstract AbstractCompositeLimit CreateCompositeLimitWithCollection(List<ILimit> limits);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 protected abstract int GetMultipleLimitValue(int numberBeingLimited, int sizeConstrainedLimitNum, int absoluteLimitNum);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 }
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 }
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49