view API/Savers/IWarFoundryFileSaverTests.cs @ 93:72b2f9a5fe8f

Re #324: Add saving of Race and System data to files * Tidy up after unit test
author IBBoard <dev@ibboard.co.uk>
date Sat, 05 Mar 2011 15:21:41 +0000
parents 43c44d0bf97f
children 10da200c7799
line wrap: on
line source

using System;
using System.IO;
using IBBoard.WarFoundry.API.Objects;
using IBBoard.WarFoundry.API.Objects.Mock;
using NUnit.Framework;
using ICSharpCode.SharpZipLib.Zip;

namespace IBBoard.WarFoundry.API.Savers
{
	public abstract class IWarFoundryFileSaverTests
	{
		[Test()]
		public void TestSaverCreatesFile()
		{
			string tempFile = Path.GetTempFileName();
			try
			{
				bool saved = GetSaver().Save(tempFile, new MockGameSystem());
				Assert.That(saved);
				Assert.That(File.Exists(tempFile));
			}
			finally
			{
				if (File.Exists(tempFile))
				{
					File.Delete(tempFile);
				}
			}
		}
		
		[Test()]
		public void TestSaverCreatesZipFile()
		{
			string tempFile = Path.GetTempFileName();
			try
			{
				GetSaver().Save(tempFile, new MockGameSystem());
				ZipFile file = new ZipFile(tempFile);
				file.Close();
			}
			finally
			{
				if (File.Exists(tempFile))
				{
					File.Delete(tempFile);
				}
			}
		}
		

		protected abstract IWarFoundryFileSaver GetSaver();
	}
}