view 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
line wrap: on
line source

using System;
using NUnit.Framework;
using System.IO;
using System.Collections.Generic;
using IBBoard.WarFoundry.API.Objects;
using NUnit.Framework.SyntaxHelpers;

namespace IBBoard.WarFoundry.API.Factories.Xml
{
	[TestFixture()]
	public class WarFoundryXmlFactoryTests
	{
		[Test()]
		public void TestFactoryHandlesMultipleFilesWithOldNamesInOneSystemZip()
		{
			ICollection<IWarFoundryObject> objs = WarFoundryXmlFactory.GetFactory().CreateObjectsFromFile(new FileInfo("testdata/multifile-zips/Test.system"));
			Assert.That(objs, Has.Count(2));
			int raceCount = 0;
			int systemCount = 0;
			
			foreach (IWarFoundryObject obj in objs)
			{
				if (obj is Race)
				{
					raceCount++;
				}
				else if (obj is GameSystem)
				{
					systemCount++;
				}
			}
			
			Assert.That(raceCount, Is.EqualTo(1));
			Assert.That(systemCount, Is.EqualTo(1));
		}
	}
}