changeset 91:98539b2fe8fa

Re #324: Add saving of Race and System data to files * Add first unit test for file savers
author IBBoard <dev@ibboard.co.uk>
date Sat, 05 Mar 2011 14:59:04 +0000
parents 5d19fee8e9dc
children 43c44d0bf97f
files API/Savers/IWarFoundryFileSaverTests.cs API/Savers/Xml/WarFoundryXmlFileSaverTests.cs IBBoard.WarFoundry.API.Tests.csproj
diffstat 3 files changed, 50 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/API/Savers/IWarFoundryFileSaverTests.cs	Sat Mar 05 14:59:04 2011 +0000
@@ -0,0 +1,31 @@
+using System;
+using System.IO;
+using IBBoard.WarFoundry.API.Objects;
+using IBBoard.WarFoundry.API.Objects.Mock;
+using NUnit.Framework;
+
+namespace IBBoard.WarFoundry.API.Savers
+{
+	public abstract class IWarFoundryFileSaverTests
+	{
+		[Test()]
+		public void TestSaverCreatesZipFile()
+		{
+			string tempFile = Path.GetTempFileName();
+			try
+			{
+				GetSaver().Save(tempFile, new MockGameSystem());
+				Assert.That(File.Exists(tempFile));
+			}
+			finally
+			{
+				if (File.Exists(tempFile))
+				{
+					File.Delete(tempFile);
+				}
+			}
+		}
+
+		protected abstract IWarFoundryFileSaver GetSaver();
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/API/Savers/Xml/WarFoundryXmlFileSaverTests.cs	Sat Mar 05 14:59:04 2011 +0000
@@ -0,0 +1,15 @@
+using System;
+using NUnit.Framework;
+using System.IO;
+
+namespace IBBoard.WarFoundry.API.Savers.Xml
+{
+	[TestFixture()]
+	public class WarFoundryXmlFileSaverTests : IWarFoundryFileSaverTests
+	{
+		protected override IWarFoundryFileSaver GetSaver()
+		{
+			return new WarFoundryXmlFileSaver();
+		}
+	}
+}
--- a/IBBoard.WarFoundry.API.Tests.csproj	Sun Feb 27 20:33:12 2011 +0000
+++ b/IBBoard.WarFoundry.API.Tests.csproj	Sat Mar 05 14:59:04 2011 +0000
@@ -90,6 +90,8 @@
     <Compile Include="API\Objects\GameSystemTest.cs" />
     <Compile Include="API\Factories\Xml\WarFoundryXmlFactoryTests.cs" />
     <Compile Include="API\EventListeningWarFoundryLoader.cs" />
+    <Compile Include="API\Savers\IWarFoundryFileSaverTests.cs" />
+    <Compile Include="API\Savers\Xml\WarFoundryXmlFileSaverTests.cs" />
   </ItemGroup>
   <ItemGroup>
     <None Include="app.config" />
@@ -338,5 +340,7 @@
   </ItemGroup>
   <ItemGroup>
     <Folder Include="testdata\multifile-zips\" />
+    <Folder Include="API\Savers\" />
+    <Folder Include="API\Savers\Xml\" />
   </ItemGroup>
 </Project>
\ No newline at end of file