view WarFoundryLoaderTest.cs @ 9:f96169484ba5

Fixes #44 - Fix API tests * Rename MockFactory to MockSystemFactory * Update test Race and System files * Update broken test to match current load methods * Remove unused "FixedFileWarFoundryLoader" that isn't applicable to new load method
author IBBoard <dev@ibboard.co.uk>
date Sun, 15 Mar 2009 15:21:58 +0000
parents 4222cfa99c78
children 8d9d49332d44
line wrap: on
line source

// This file (WarFoundryLoaderTest.cs) is a part of the IBBoard.WarFoundry.API.Tests project and is copyright 2009 IBBoard.
//
// The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.

using System;
using System.IO;
using NUnit.Framework;
using IBBoard.WarFoundry.API.Objects;
using IBBoard.WarFoundry.API.Factories.Xml;

namespace IBBoard.WarFoundry.API.Factories
{
	[TestFixture()]
	public class WarFoundryLoaderTest
	{
		private AbstractNativeWarFoundryFactory sysFactory;
				
		[Test()]
		public void TestLoadWithoutFactoriesCompletesWithoutError()
		{
			WarFoundryLoader.GetDefault().LoadFiles();
		}
		
		[Test()]
		public void TestLoadingSystemCompletesWithoutError()
		{
			WarFoundryLoader loader = WarFoundryLoader.GetDefault();
			DirectoryInfo dir = new DirectoryInfo("testdata");
			loader.RegisterFactory(GetSystemFactory());
			loader.AddLoadDirectory(dir);
			loader.LoadFiles();
			Assert.Greater(loader.GetGameSystems().Length, 0);
			loader.RemoveLoadDirectory(dir);
			loader.UnregisterFactory(GetSystemFactory());
		}
				
		private AbstractNativeWarFoundryFactory GetSystemFactory()
		{
			if (sysFactory == null)
			{
				sysFactory = new MockSystemFactory();
			}
			
			return sysFactory;
		}
	}
}