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
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
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 namespace IBBoard.Limits
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 public abstract class AbstractCompositeLimitTest
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 [Test()]
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 public void TestCompositeWithZeroLimits()
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 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
15 }
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 [Test()]
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 public void TestCompositeWithOneLimitReturnsLimitValue()
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 NumericSizeConstrainedLimit limit = new NumericSizeConstrainedLimit(10);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithLimit(limit);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 Assert.That(compositeLimit.GetLimit(1), Is.EqualTo(limit.GetLimit(1)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 Assert.That(compositeLimit.GetLimit(10), Is.EqualTo(limit.GetLimit(10)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 Assert.That(compositeLimit.GetLimit(100), Is.EqualTo(limit.GetLimit(100)));
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 }
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 [Test()]
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 public void TestCompositeWithMultipleLimitsReturnsCorrectValues()
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 {
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 List<ILimit> limits = new List<ILimit>();
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 int sizeConstrainedLimitNum = 10;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 NumericSizeConstrainedLimit limit1 = new NumericSizeConstrainedLimit(sizeConstrainedLimitNum);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 limits.Add(limit1);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 int absoluteLimitNum = 5;
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 AbsoluteNumericLimit limit2 = new AbsoluteNumericLimit(absoluteLimitNum);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 limits.Add(limit2);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 AbstractCompositeLimit compositeLimit = CreateCompositeLimitWithCollection(limits);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 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
39 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
40 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
41 }
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 protected abstract AbstractCompositeLimit CreateCompositeLimitWithLimit(ILimit limit);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
44 protected abstract AbstractCompositeLimit CreateCompositeLimitWithCollection(List<ILimit> limits);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 protected abstract int GetMultipleLimitValue(int numberBeingLimited, int sizeConstrainedLimitNum, int absoluteLimitNum);
57b5d27e95fb Fixes #45: Create composite limit
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 }
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