Mercurial > repos > IBDev-IBBoard.WarFoundry.API.Tests
comparison API/Factories/Xml/WarFoundryXmlLimitParserTest.cs @ 238:e173c5512067
* Update to v2.6 of NUnit and new syntax/API changes
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 28 Apr 2013 19:32:38 +0100 |
parents | 7f9e1fef069e |
children |
comparison
equal
deleted
inserted
replaced
237:833f72be715a | 238:e173c5512067 |
---|---|
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. | 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 using System.IO; | 4 using System.IO; |
5 using System.Xml; | 5 using System.Xml; |
6 using NUnit.Framework; | 6 using NUnit.Framework; |
7 using IBBoard.Limits; | 7 using IBBoard.Limits; |
8 using NUnit.Framework.SyntaxHelpers; | |
9 using IBBoard.IO; | 8 using IBBoard.IO; |
10 namespace IBBoard.WarFoundry.API.Factories.Xml | 9 namespace IBBoard.WarFoundry.API.Factories.Xml |
11 { | 10 { |
12 [TestFixture()] | 11 [TestFixture()] |
13 public class WarFoundryXmlLimitParserTest | 12 public class WarFoundryXmlLimitParserTest |
17 { | 16 { |
18 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/composite-max-limit.xml")); | 17 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/composite-max-limit.xml")); |
19 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); | 18 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); |
20 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); | 19 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); |
21 ILimit limit = parser.GetLimitFromElement(limitElem); | 20 ILimit limit = parser.GetLimitFromElement(limitElem); |
22 Assert.That(limit, Is.InstanceOfType(typeof(CompositeMaximumLimit))); | 21 Assert.That(limit, Is.InstanceOf(typeof(CompositeMaximumLimit))); |
23 Assert.That(limit.GetLimit(1), Is.EqualTo(5)); | 22 Assert.That(limit.GetLimit(1), Is.EqualTo(5)); |
24 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); | 23 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); |
25 Assert.That(limit.GetLimit(10), Is.EqualTo(10)); | 24 Assert.That(limit.GetLimit(10), Is.EqualTo(10)); |
26 Assert.That(limit.GetLimit(20), Is.EqualTo(10)); | 25 Assert.That(limit.GetLimit(20), Is.EqualTo(10)); |
27 } | 26 } |
31 { | 30 { |
32 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/composite-min-limit.xml")); | 31 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/composite-min-limit.xml")); |
33 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); | 32 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); |
34 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); | 33 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); |
35 ILimit limit = parser.GetLimitFromElement(limitElem); | 34 ILimit limit = parser.GetLimitFromElement(limitElem); |
36 Assert.That(limit, Is.InstanceOfType(typeof(CompositeMinimumLimit))); | 35 Assert.That(limit, Is.InstanceOf(typeof(CompositeMinimumLimit))); |
37 Assert.That(limit.GetLimit(1), Is.EqualTo(1)); | 36 Assert.That(limit.GetLimit(1), Is.EqualTo(1)); |
38 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); | 37 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); |
39 Assert.That(limit.GetLimit(10), Is.EqualTo(5)); | 38 Assert.That(limit.GetLimit(10), Is.EqualTo(5)); |
40 Assert.That(limit.GetLimit(20), Is.EqualTo(5)); | 39 Assert.That(limit.GetLimit(20), Is.EqualTo(5)); |
41 } | 40 } |
45 { | 44 { |
46 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/composite-max-limit-nested.xml")); | 45 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/composite-max-limit-nested.xml")); |
47 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); | 46 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); |
48 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); | 47 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); |
49 ILimit limit = parser.GetLimitFromElement(limitElem); | 48 ILimit limit = parser.GetLimitFromElement(limitElem); |
50 Assert.That(limit, Is.InstanceOfType(typeof(CompositeMaximumLimit))); | 49 Assert.That(limit, Is.InstanceOf(typeof(CompositeMaximumLimit))); |
51 Assert.That(limit.GetLimit(1), Is.EqualTo(5)); | 50 Assert.That(limit.GetLimit(1), Is.EqualTo(5)); |
52 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); | 51 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); |
53 Assert.That(limit.GetLimit(10), Is.EqualTo(5)); | 52 Assert.That(limit.GetLimit(10), Is.EqualTo(5)); |
54 } | 53 } |
55 | 54 |
65 { | 64 { |
66 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/absolute-limit.xml")); | 65 XmlElement document = SingleXmlObjectLoader.CreateDocumentElementFromFile(new FileInfo("testdata/limits/absolute-limit.xml")); |
67 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); | 66 XmlElement limitElem = WarFoundryXmlFactoryUtils.SelectSingleElement(document, "//race:maxLimit/*"); |
68 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); | 67 WarFoundryXmlLimitParser parser = new WarFoundryXmlLimitParser(); |
69 ILimit limit = parser.GetLimitFromElement(limitElem); | 68 ILimit limit = parser.GetLimitFromElement(limitElem); |
70 Assert.That(limit, Is.InstanceOfType(typeof(AbsoluteNumericLimit))); | 69 Assert.That(limit, Is.InstanceOf(typeof(AbsoluteNumericLimit))); |
71 Assert.That(limit.GetLimit(1), Is.EqualTo(5)); | 70 Assert.That(limit.GetLimit(1), Is.EqualTo(5)); |
72 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); | 71 Assert.That(limit.GetLimit(5), Is.EqualTo(5)); |
73 Assert.That(limit.GetLimit(10), Is.EqualTo(5)); | 72 Assert.That(limit.GetLimit(10), Is.EqualTo(5)); |
74 } | 73 } |
75 } | 74 } |