view WarFoundryLoaderTest.cs @ 5:90f63edddc94

Re #30 - Migrate WarFoundry to .csproj * Migrate API tests to .csproj and remove .mdp Also remove old test results from source control
author IBBoard <dev@ibboard.co.uk>
date Tue, 17 Feb 2009 16:30:12 +0000
parents 4222cfa99c78
children f96169484ba5
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;

namespace IBBoard.WarFoundry.API.Factories
{
	[TestFixture()]
	public class WarFoundryLoaderTest
	{
		private AbstractNativeWarFoundryFactory factory;
				
		[Test()]
		public void TestLoadWithoutFactoriesCompletesWithoutError()
		{
			WarFoundryLoader.GetDefault().LoadFiles();
		}
		
		[Test()]
		public void TestLoadingSystemCompletesWithoutError()
		{
			WarFoundryLoader loader = GetSystemLoader();
			DirectoryInfo dir = new DirectoryInfo(".");
			loader.RegisterFactory(GetFactory());
			loader.AddLoadDirectory(dir);
			loader.LoadFiles();
			Assert.Greater(loader.GetGameSystems().Length, 0);
			loader.RemoveLoadDirectory(dir);
			loader.UnregisterFactory(GetFactory());
		}
				
		private AbstractNativeWarFoundryFactory GetFactory()
		{
			if (factory == null)
			{
				factory = new MockFactory();
			}
			
			return factory;
		}
		
		private WarFoundryLoader GetSystemLoader()
		{
			return new FixedFileWarFoundryLoader(new MockSystemZipFile());
		}
		
		private WarFoundryLoader GetRaceLoader()
		{
			return new FixedFileWarFoundryLoader(new MockRaceZipFile());
		}
	}
}