annotate API/Factories/Xml/WarFoundryXmlFactoryTests.cs @ 87:5c04db41d643

Re #253: Allow multiple data files in a single zip * Add test data and initial test
author IBBoard <dev@ibboard.co.uk>
date Sat, 26 Feb 2011 20:14:29 +0000
parents
children 90dee8d781ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
87
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 using System;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 using NUnit.Framework;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 using System.IO;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 using System.Collections.Generic;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 using IBBoard.WarFoundry.API.Objects;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 using NUnit.Framework.SyntaxHelpers;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 namespace IBBoard.WarFoundry.API.Factories.Xml
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 {
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 [TestFixture()]
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 public class WarFoundryXmlFactoryTests
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 {
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 [Test()]
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14 public void TestFactoryHandlesMultipleFilesWithOldNamesInOneSystemZip()
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 {
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.system"));
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 Assert.That(objs, Has.Count(2));
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 int raceCount = 0;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19 int systemCount = 0;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 foreach (IWarFoundryObject obj in objs)
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 {
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 if (obj is Race)
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 {
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 raceCount++;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 }
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 else if (obj is GameSystem)
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 {
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29 systemCount++;
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 }
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 }
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 Assert.That(raceCount, Is.EqualTo(1));
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 Assert.That(systemCount, Is.EqualTo(1));
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 }
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }
5c04db41d643 Re #253: Allow multiple data files in a single zip
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
37 }